[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 07:48:34 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 1ea2ad82ec4bfda3d6150077ee629a8fffac83cd
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jul 25 01:21:52 2003 +0000
Fixed 3279910. Change the way we draw dragged link to use
WebKit's measurement and drawing. Also made the look match
the bookmarks bar text.
Reviewed by Maciej.
* Misc.subproj/WebKitNSStringExtras.h:
* Misc.subproj/WebKitNSStringExtras.m:
(-[NSString _web_drawDoubledAtPoint:withTopColor:bottomColor:font:]):
* WebView.subproj/WebHTMLViewPrivate.h:
* WebView.subproj/WebHTMLViewPrivate.m:
(-[WebHTMLView _dragImageForLinkElement:]):
(-[WebHTMLView _handleMouseDragged:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 71c93cd..3c925d0 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,21 @@
2003-07-24 Richard Williamson <rjw at apple.com>
+ Fixed 3279910. Change the way we draw dragged link to use
+ WebKit's measurement and drawing. Also made the look match
+ the bookmarks bar text.
+
+ Reviewed by Maciej.
+
+ * Misc.subproj/WebKitNSStringExtras.h:
+ * Misc.subproj/WebKitNSStringExtras.m:
+ (-[NSString _web_drawDoubledAtPoint:withTopColor:bottomColor:font:]):
+ * WebView.subproj/WebHTMLViewPrivate.h:
+ * WebView.subproj/WebHTMLViewPrivate.m:
+ (-[WebHTMLView _dragImageForLinkElement:]):
+ (-[WebHTMLView _handleMouseDragged:]):
+
+2003-07-24 Richard Williamson <rjw at apple.com>
+
Removed unnecessary log.
Reviewed by John.
diff --git a/WebKit/Misc.subproj/WebKitNSStringExtras.h b/WebKit/Misc.subproj/WebKitNSStringExtras.h
index 132866f..c220ae4 100644
--- a/WebKit/Misc.subproj/WebKitNSStringExtras.h
+++ b/WebKit/Misc.subproj/WebKitNSStringExtras.h
@@ -10,6 +10,7 @@
@interface NSString (WebKitExtras)
- (void)_web_drawAtPoint:(NSPoint)point font:(NSFont *)font textColor:(NSColor *)textColor;
+- (void)_web_drawDoubledAtPoint:(NSPoint)textPoint withTopColor:(NSColor *)topColor bottomColor:(NSColor *)bottomColor font:(NSFont *)font;
- (float)_web_widthWithFont:(NSFont *)font;
diff --git a/WebKit/Misc.subproj/WebKitNSStringExtras.m b/WebKit/Misc.subproj/WebKitNSStringExtras.m
index 629c820..7229454 100644
--- a/WebKit/Misc.subproj/WebKitNSStringExtras.m
+++ b/WebKit/Misc.subproj/WebKitNSStringExtras.m
@@ -48,6 +48,25 @@ static BOOL canUseFastRenderer (const UniChar *buffer, unsigned length)
free(buffer);
}
+- (void)_web_drawDoubledAtPoint:(NSPoint)textPoint
+ withTopColor:(NSColor *)topColor
+ bottomColor:(NSColor *)bottomColor
+ font:(NSFont *)font
+{
+ // turn off font smoothing so translucent text draws correctly (Radar 3118455)
+ [NSGraphicsContext saveGraphicsState];
+ CGContextSetShouldSmoothFonts([[NSGraphicsContext currentContext] graphicsPort], false);
+ [self _web_drawAtPoint:textPoint
+ font:font
+ textColor:bottomColor];
+
+ textPoint.y += 1;
+ [self _web_drawAtPoint:textPoint
+ font:font
+ textColor:topColor];
+ [NSGraphicsContext restoreGraphicsState];
+}
+
- (float)_web_widthWithFont:(NSFont *)font
{
unsigned length = [self length];
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index 322cc10..722fda4 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -65,7 +65,7 @@
- (void)_frameOrBoundsChanged;
-- (NSImage *)_dragImageForElement:(NSDictionary *)element;
+- (NSImage *)_dragImageForLinkElement:(NSDictionary *)element;
- (void)_handleMouseDragged:(NSEvent *)event;
- (void)_handleAutoscrollForMouseDragged:(NSEvent *)event;
- (BOOL)_mayStartDragWithMouseDragged:(NSEvent *)event;
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index 3f1c267..765c690 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -18,6 +18,7 @@
#import <WebKit/WebFrameViewPrivate.h>
#import <WebKit/WebHTMLView.h>
#import <WebKit/WebImageRenderer.h>
+#import <WebKit/WebKitNSStringExtras.h>
#import <WebKit/WebNSImageExtras.h>
#import <WebKit/WebNSPasteboardExtras.h>
#import <WebKit/WebNSURLExtras.h>
@@ -44,8 +45,10 @@
#define DRAG_LABEL_BORDER_X 4.0
#define DRAG_LABEL_BORDER_Y 2.0
#define DRAG_LABEL_RADIUS 5.0
+#define DRAG_LABEL_BORDER_Y_OFFSET 2.0
#define MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP 120.0
+#define MAX_DRAG_LABEL_WIDTH 320.0
#import <CoreGraphics/CGStyle.h>
#import <CoreGraphics/CGSTypes.h>
@@ -423,12 +426,12 @@ static WebHTMLView *lastHitView = nil;
}
--(NSImage *)_dragImageForElement:(NSDictionary *)element
+-(NSImage *)_dragImageForLinkElement:(NSDictionary *)element
{
NSURL *linkURL = [element objectForKey: WebElementLinkURLKey];
BOOL drawURLString = YES;
- BOOL clipURLString = NO;
+ BOOL clipURLString = NO, clipLabelString = NO;
NSString *label = [element objectForKey: WebElementLinkLabelKey];
NSString *urlString = [linkURL absoluteString];
@@ -438,21 +441,26 @@ static WebHTMLView *lastHitView = nil;
label = urlString;
}
- // FIXME: This mega-block of code needs to be cleaned-up or put into another method.
- NSFont *labelFont = [NSFont systemFontOfSize: 12.0];
- NSFont *urlFont = [NSFont systemFontOfSize: 8.0];
- NSDictionary *labelAttributes = [NSDictionary dictionaryWithObjectsAndKeys: labelFont, NSFontAttributeName, [NSColor whiteColor], NSForegroundColorAttributeName, nil];
- NSDictionary *urlAttributes = [NSDictionary dictionaryWithObjectsAndKeys: urlFont, NSFontAttributeName, [NSColor whiteColor], NSForegroundColorAttributeName, nil];
- NSSize labelSize = [label sizeWithAttributes: labelAttributes];
+ NSFont *labelFont = [[NSFontManager sharedFontManager] convertFont:[NSFont systemFontOfSize:12.0]
+ toHaveTrait:NSBoldFontMask];
+ NSFont *urlFont = [NSFont systemFontOfSize: 10.0];
+ 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;
- imageSize.height += labelSize.height + DRAG_LABEL_BORDER_Y *2;
+ imageSize.height += labelSize.height + DRAG_LABEL_BORDER_Y * 2;
if (drawURLString) {
- urlStringSize = [urlString sizeWithAttributes: urlAttributes];
+ urlStringSize.width = [urlString _web_widthWithFont: urlFont];
+ urlStringSize.height = [urlFont ascender] - [urlFont descender];
imageSize.height += urlStringSize.height;
- // Clip the url string to 2.5 times the width of the label.
- if (urlStringSize.width > MAX(2.5 * labelSize.width, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP)) {
- imageSize.width = MAX((labelSize.width * 2.5) + DRAG_LABEL_BORDER_X * 2, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
+ if (urlStringSize.width > MAX_DRAG_LABEL_WIDTH) {
+ imageSize.width = MAX(MAX_DRAG_LABEL_WIDTH + DRAG_LABEL_BORDER_X * 2, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
clipURLString = YES;
} else {
imageSize.width = MAX(labelSize.width + DRAG_LABEL_BORDER_X * 2, urlStringSize.width + DRAG_LABEL_BORDER_X * 2);
@@ -461,7 +469,7 @@ static WebHTMLView *lastHitView = nil;
NSImage *dragImage = [[[NSImage alloc] initWithSize: imageSize] autorelease];
[dragImage lockFocus];
- [[NSColor colorWithCalibratedRed: 0.5 green: 0.5 blue: 0.5 alpha: 0.8] set];
+ [[NSColor colorWithCalibratedRed: 0.7 green: 0.7 blue: 0.7 alpha: 0.8] set];
// Drag a rectangle with rounded corners/
NSBezierPath *path = [NSBezierPath bezierPath];
@@ -474,32 +482,21 @@ static WebHTMLView *lastHitView = nil;
[path appendBezierPathWithRect: NSMakeRect(0, DRAG_LABEL_RADIUS, DRAG_LABEL_RADIUS + 10, imageSize.height - 2 * DRAG_LABEL_RADIUS)];
[path appendBezierPathWithRect: NSMakeRect(imageSize.width - DRAG_LABEL_RADIUS - 20,DRAG_LABEL_RADIUS, DRAG_LABEL_RADIUS + 20, imageSize.height - 2 * DRAG_LABEL_RADIUS)];
[path fill];
-
- // Draw the label with a slight shadow.
- CGShadowStyle shadow;
- CGSGenericObj style;
-
- shadow.version = 0;
- shadow.elevation = kCGShadowElevationDefault;
- shadow.azimuth = 136.869995;
- shadow.ambient = 0.317708;
- shadow.height = 2.187500;
- shadow.radius = 1.875000;
- shadow.saturation = kCGShadowSaturationDefault;
- style = CGStyleCreateShadow(&shadow);
- [NSGraphicsContext saveGraphicsState];
- CGContextSetStyle([[NSGraphicsContext currentContext] graphicsPort], style);
-
+
+ NSColor *topColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.75];
+ NSColor *bottomColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.5];
if (drawURLString) {
- if (clipURLString) {
- urlString = [WebStringTruncator rightTruncateString: urlString toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2) withFont:urlFont];
- }
- [urlString drawAtPoint: NSMakePoint(DRAG_LABEL_BORDER_X, DRAG_LABEL_BORDER_Y) withAttributes: urlAttributes];
+ if (clipURLString)
+ urlString = [WebStringTruncator centerTruncateString: urlString toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2) withFont:urlFont];
+
+ [urlString _web_drawDoubledAtPoint:NSMakePoint(DRAG_LABEL_BORDER_X, DRAG_LABEL_BORDER_Y - [urlFont descender])
+ withTopColor:topColor bottomColor:bottomColor font:urlFont];
}
- [label drawAtPoint: NSMakePoint (DRAG_LABEL_BORDER_X, DRAG_LABEL_BORDER_Y + urlStringSize.height) withAttributes: labelAttributes];
-
- [NSGraphicsContext restoreGraphicsState];
- CGStyleRelease(style);
+
+ if (clipLabelString)
+ label = [WebStringTruncator rightTruncateString: label toWidth:imageSize.width - (DRAG_LABEL_BORDER_X * 2) withFont:labelFont];
+ [label _web_drawDoubledAtPoint:NSMakePoint (DRAG_LABEL_BORDER_X, imageSize.height - DRAG_LABEL_BORDER_Y_OFFSET - [labelFont ascender])
+ withTopColor:topColor bottomColor:bottomColor font:labelFont];
[dragImage unlockFocus];
@@ -552,7 +549,7 @@ static WebHTMLView *lastHitView = nil;
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
NSString *label = [element objectForKey:WebElementLinkLabelKey];
[pasteboard _web_writeURL:linkURL andTitle:label withOwner:self];
- NSImage *dragImage = [self _dragImageForElement:element];
+ NSImage *dragImage = [self _dragImageForLinkElement:element];
NSSize offset = NSMakeSize([dragImage size].width / 2, -DRAG_LABEL_BORDER_Y);
[self dragImage:dragImage
at:NSMakePoint(mouseDraggedPoint.x - offset.width, mouseDraggedPoint.y - offset.height)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list