WebKit/mac: WebKit part of making the appearance of the full-screen video HUD match
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Nov 2009 17:03:14 +0000 (17:03 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Nov 2009 17:03:14 +0000 (17:03 +0000)
QuickTime Player X’s HUD.

Reviewed by John Sullivan.

* WebView/WebVideoFullscreenHUDWindowController.h: Removed unnecessary
#import statements, cleaned up style, and changed _timeline,
_volumeSlider and _playButton to have more specific types.
* WebView/WebVideoFullscreenHUDWindowController.mm: Updated #import
statements.
(webkit_CGFloor): Added this helper function.
(-[WebVideoFullscreenHUDWindowController init]): Cleaned up style.
(createTimeTextField): Changed to use the bold system font.
(-[WebVideoFullscreenHUDWindowController windowDidLoad]): Changed the
subviews’ metrics and the text fields’ text alignment.
(-[WebVideoFullscreenHUDWindowController updateTime]): Avoid conversion
from double to float.
(stringToTimeTextAttributed): Removed this useless function that
returned an NSAttributedString masquerading as an NSString.
(-[WebVideoFullscreenHUDWindowController remainingTimeText]): Removed
call to stringToTimeTextAttributed().
(-[WebVideoFullscreenHUDWindowController elapsedTimeText]): Ditto.

WebKitLibraries: WebKitSystemInterface part of making the appearance of the full-screen video HUD match
QuickTime Player X’s HUD.

Reviewed by John Sullivan.

* libWebKitSystemInterfaceLeopard.a:
* libWebKitSystemInterfaceSnowLeopard.a:
* libWebKitSystemInterfaceTiger.a:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@50410 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/mac/ChangeLog
WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h
WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm
WebKitLibraries/ChangeLog
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a
WebKitLibraries/libWebKitSystemInterfaceTiger.a

index a8c4d9a..6e9f880 100644 (file)
@@ -1,3 +1,28 @@
+2009-11-02  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by John Sullivan.
+
+        WebKit part of making the appearance of the full-screen video HUD match
+        QuickTime Player X’s HUD.
+
+        * WebView/WebVideoFullscreenHUDWindowController.h: Removed unnecessary
+        #import statements, cleaned up style, and changed _timeline,
+        _volumeSlider and _playButton to have more specific types.
+        * WebView/WebVideoFullscreenHUDWindowController.mm: Updated #import
+        statements.
+        (webkit_CGFloor): Added this helper function.
+        (-[WebVideoFullscreenHUDWindowController init]): Cleaned up style.
+        (createTimeTextField): Changed to use the bold system font.
+        (-[WebVideoFullscreenHUDWindowController windowDidLoad]): Changed the
+        subviews’ metrics and the text fields’ text alignment.
+        (-[WebVideoFullscreenHUDWindowController updateTime]): Avoid conversion
+        from double to float.
+        (stringToTimeTextAttributed): Removed this useless function that
+        returned an NSAttributedString masquerading as an NSString.
+        (-[WebVideoFullscreenHUDWindowController remainingTimeText]): Removed
+        call to stringToTimeTextAttributed().
+        (-[WebVideoFullscreenHUDWindowController elapsedTimeText]): Ditto.
+
 2009-11-02  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Beth Dakin.
index 1ffa596..34020e5 100644 (file)
 
 #if ENABLE(VIDEO)
 
-#import <Cocoa/Cocoa.h>
-#import <WebCore/HTMLMediaElement.h>
+namespace WebCore {
+    class HTMLMediaElement;
+}
 
 @protocol WebVideoFullscreenHUDWindowControllerDelegate;
 
-@interface WebVideoFullscreenHUDWindowController : NSWindowController {
-@private
+@interface WebVideoFullscreenHUDWindowController : NSWindowController
+{
     id<WebVideoFullscreenHUDWindowControllerDelegate> _delegate;
     NSTimer *_timelineUpdateTimer;
 #if !defined(BUILDING_ON_TIGER)
     BOOL _mouseIsInHUD;
     BOOL _isEndingFullscreen;
 
-    NSControl *_timeline;
+    NSSlider *_timeline;
     NSTextField *_remainingTimeText;
     NSTextField *_elapsedTimeText;
-    NSControl *_volumeSlider;
-    NSControl *_playButton;
+    NSSlider *_volumeSlider;
+    NSButton *_playButton;
 }
+
 - (id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate;
 - (void)setDelegate:(id<WebVideoFullscreenHUDWindowControllerDelegate>)delegate;
 - (void)fadeWindowIn;
index 394f0b2..523ff4b 100644 (file)
 
 #import "WebVideoFullscreenHUDWindowController.h"
 
-#import <QTKit/QTKit.h>
 #import "WebKitSystemInterface.h"
 #import "WebTypesInternal.h"
-#import <wtf/RetainPtr.h>
-#import <limits>
+#import <JavaScriptCore/RetainPtr.h>
+#import <JavaScriptCore/UnusedParam.h>
+#import <WebCore/HTMLMediaElement.h>
 
 using namespace std;
 
+static inline CGFloat webkit_CGFloor(CGFloat value)
+{
+    if (sizeof(value) == sizeof(float))
+        return floorf(value);
+    return floor(value);
+}
+
 #define HAVE_MEDIA_CONTROL (!defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD))
 
 @interface WebVideoFullscreenHUDWindowController (Private) <NSWindowDelegate>
@@ -149,7 +156,7 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3;
 
 - (id)init
 {
-    NSWindowwindow = [[WebVideoFullscreenHUDWindow alloc] initWithContentRect:NSMakeRect(0, 0, windowWidth, windowHeight)
+    NSWindow *window = [[WebVideoFullscreenHUDWindow alloc] initWithContentRect:NSMakeRect(0, 0, windowWidth, windowHeight)
                             styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
     self = [super initWithWindow:window];
     [window setDelegate:self];
@@ -326,7 +333,7 @@ static NSTextField *createTimeTextField(NSRect frame)
     NSTextField *textField = [[NSTextField alloc] initWithFrame:frame];
     [textField setTextColor:[NSColor whiteColor]];
     [textField setBordered:NO];
-    [textField setFont:[NSFont systemFontOfSize:10]];
+    [textField setFont:[NSFont boldSystemFontOfSize:10]];
     [textField setDrawsBackground:NO];
     [textField setBezeled:NO];
     [textField setEditable:NO];
@@ -336,10 +343,25 @@ static NSTextField *createTimeTextField(NSRect frame)
 
 - (void)windowDidLoad
 {
-    static const CGFloat kMargin = 9;
-    static const CGFloat kMarginTop = 9;
-    static const CGFloat kButtonSize = 25;
-    static const CGFloat kButtonMiniSize = 16;
+    static const CGFloat horizontalMargin = 10;
+    static const CGFloat playButtonWidth = 41;
+    static const CGFloat playButtonHeight = 35;
+    static const CGFloat playButtonTopMargin = 4;
+    static const CGFloat volumeSliderWidth = 50;
+    static const CGFloat volumeSliderHeight = 13;
+    static const CGFloat volumeButtonWidth = 18;
+    static const CGFloat volumeButtonHeight = 16;
+    static const CGFloat volumeUpButtonLeftMargin = 4;
+    static const CGFloat volumeControlsTopMargin = 13;
+    static const CGFloat exitFullScreenButtonWidth = 25;
+    static const CGFloat exitFullScreenButtonHeight = 21;
+    static const CGFloat exitFullScreenButtonTopMargin = 11;
+    static const CGFloat timelineWidth = 315;
+    static const CGFloat timelineHeight = 14;
+    static const CGFloat timelineBottomMargin = 7;
+    static const CGFloat timeTextFieldWidth = 54;
+    static const CGFloat timeTextFieldHeight = 13;
+    static const CGFloat timeTextFieldHorizontalMargin = 7;
 
     NSWindow *window = [self window];
     ASSERT(window);
@@ -356,67 +378,61 @@ static NSTextField *createTimeTextField(NSRect frame)
 #endif
     [background release];    
 
-    NSView *contentView = [[self window] contentView];
+    NSView *contentView = [window contentView];
 
-    CGFloat top = windowHeight - kMarginTop;
-    CGFloat center = (windowWidth - kButtonSize) / 2;
-    _playButton = createControlWithMediaUIControlType(WKMediaUIControlPlayPauseButton, NSMakeRect(center, top - kButtonSize, kButtonSize, kButtonSize));
+    CGFloat center = webkit_CGFloor((windowWidth - playButtonWidth) / 2);
+    _playButton = (NSButton *)createControlWithMediaUIControlType(WKMediaUIControlPlayPauseButton, NSMakeRect(center, windowHeight - playButtonTopMargin - playButtonHeight, playButtonWidth, playButtonHeight));
     [_playButton setTarget:self];
     [_playButton setAction:@selector(togglePlaying:)];
     [contentView addSubview:_playButton];
 
-    CGFloat closeToRight = windowWidth - 2 * kMargin - kButtonMiniSize;
-    NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, top - kButtonSize / 2 - kButtonMiniSize / 2, kButtonMiniSize, kButtonMiniSize));
+    CGFloat closeToRight = windowWidth - horizontalMargin - exitFullScreenButtonWidth;
+    NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, windowHeight - exitFullScreenButtonTopMargin - exitFullScreenButtonHeight, exitFullScreenButtonWidth, exitFullScreenButtonHeight));
     [exitFullscreenButton setAction:@selector(exitFullscreen:)];
     [exitFullscreenButton setTarget:self];
     [contentView addSubview:exitFullscreenButton];
     [exitFullscreenButton release];
     
-    CGFloat left = kMargin;
-    NSControl *volumeDownButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeDownButton, NSMakeRect(left, top - kButtonSize / 2 - kButtonMiniSize / 2, kButtonMiniSize, kButtonMiniSize));
+    CGFloat volumeControlsBottom = windowHeight - volumeControlsTopMargin - volumeButtonHeight;
+    CGFloat left = horizontalMargin;
+    NSControl *volumeDownButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeDownButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight));
     [contentView addSubview:volumeDownButton];
     [volumeDownButton setTarget:self];
     [volumeDownButton setAction:@selector(setVolumeToZero:)];
     [volumeDownButton release];
 
-    static const int volumeSliderWidth = 50;
-
-    left = kMargin + kButtonMiniSize;
-    _volumeSlider = createControlWithMediaUIControlType(WKMediaUIControlSlider, NSMakeRect(left, top - kButtonSize / 2 - kButtonMiniSize / 2, volumeSliderWidth, kButtonMiniSize));
+    left += volumeButtonWidth;
+    _volumeSlider = (NSSlider *)createControlWithMediaUIControlType(WKMediaUIControlSlider, NSMakeRect(left, volumeControlsBottom + webkit_CGFloor((volumeButtonHeight - volumeSliderHeight) / 2), volumeSliderWidth, volumeSliderHeight));
     [_volumeSlider setValue:[NSNumber numberWithDouble:[self maxVolume]] forKey:@"maxValue"];
     [_volumeSlider setTarget:self];
     [_volumeSlider setAction:@selector(volumeChanged:)];
     [contentView addSubview:_volumeSlider];
 
-    left = kMargin + kButtonMiniSize + volumeSliderWidth + kButtonMiniSize / 2;
-    NSControl *volumeUpButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeUpButton, NSMakeRect(left, top - kButtonSize / 2 - kButtonMiniSize / 2, kButtonMiniSize, kButtonMiniSize));
+    left += volumeSliderWidth + volumeUpButtonLeftMargin;
+    NSControl *volumeUpButton = createControlWithMediaUIControlType(WKMediaUIControlVolumeUpButton, NSMakeRect(left, volumeControlsBottom, volumeButtonWidth, volumeButtonHeight));
     [volumeUpButton setTarget:self];
     [volumeUpButton setAction:@selector(setVolumeToMaximum:)];
     [contentView addSubview:volumeUpButton];
     [volumeUpButton release];
-    
-    static const int timeTextWidth = 50;
-    static const int sliderHeight = 13;
-    static const int sliderMarginFixup = 4;
 
 #ifdef HAVE_MEDIA_CONTROL
-    _timeline = WKCreateMediaUIControl(WKMediaUIControlTimeline);
+    _timeline = (NSSlider *)WKCreateMediaUIControl(WKMediaUIControlTimeline);
 #else
     _timeline = [[NSSlider alloc] init];
 #endif
     [_timeline setTarget:self];
     [_timeline setAction:@selector(timelinePositionChanged:)];
-    [_timeline setFrame:NSMakeRect(kMargin + timeTextWidth + kMargin/2, kMargin - sliderMarginFixup, windowWidth - 2 * (kMargin - sliderMarginFixup) - kMargin * 2 - 2 * timeTextWidth, sliderHeight)];
+    [_timeline setFrame:NSMakeRect(webkit_CGFloor((windowWidth - timelineWidth) / 2), timelineBottomMargin, timelineWidth, timelineHeight)];
     [contentView addSubview:_timeline];
 
-    static const int timeTextHeight = 11;
-
-    _elapsedTimeText = createTimeTextField(NSMakeRect(kMargin, kMargin, timeTextWidth, timeTextHeight));
+    _elapsedTimeText = createTimeTextField(NSMakeRect(timeTextFieldHorizontalMargin, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight));
+    [_elapsedTimeText setAlignment:NSLeftTextAlignment];
     [contentView addSubview:_elapsedTimeText];
 
-    _remainingTimeText = createTimeTextField(NSMakeRect(windowWidth - kMargin - timeTextWidth, kMargin, timeTextWidth, timeTextHeight));
+    _remainingTimeText = createTimeTextField(NSMakeRect(windowWidth - timeTextFieldHorizontalMargin - timeTextFieldWidth, timelineBottomMargin, timeTextFieldWidth, timeTextFieldHeight));
+    [_remainingTimeText setAlignment:NSRightTextAlignment];
     [contentView addSubview:_remainingTimeText];
-    
+
     [window recalculateKeyViewLoop];
     [window setInitialFirstResponder:_playButton];
     [window center];
@@ -437,16 +453,12 @@ static NSTextField *createTimeTextField(NSRect frame)
     [self updateVolume];
 
     [_timeline setFloatValue:[self currentTime]];
-    [(NSSlider*)_timeline setMaxValue:[self duration]];
+    [_timeline setMaxValue:[self duration]];
 
     [_remainingTimeText setStringValue:[self remainingTimeText]];
     [_elapsedTimeText setStringValue:[self elapsedTimeText]];
 }
 
-- (void)fastForward
-{
-}
-
 - (void)timelinePositionChanged:(id)sender
 {
     [self setCurrentTime:[_timeline floatValue]];
@@ -567,7 +579,7 @@ static NSString *timeToString(double time)
 {
     if (!isfinite(time))
         time = 0;
-    int seconds = (int)fabsf(time); 
+    int seconds = fabs(time); 
     int hours = seconds / (60 * 60);
     int minutes = (seconds / 60) % 60;
     seconds %= 60;
@@ -582,29 +594,13 @@ static NSString *timeToString(double time)
     
 }
 
-static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment align)
-{
-    NSShadow *blackShadow = [[NSShadow alloc] init];
-    [blackShadow setShadowColor:[NSColor blackColor]];
-    [blackShadow setShadowBlurRadius:0];
-    [blackShadow setShadowOffset:NSMakeSize(0, -1)];
-    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
-    [style setAlignment:align];
-    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:blackShadow, NSShadowAttributeName, style, NSParagraphStyleAttributeName, nil];
-    [style release];
-    [blackShadow release];
-
-    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:string attributes:dict];
-    return [attrString autorelease];    
-}
-
 - (NSString *)remainingTimeText
 {
     if (![_delegate mediaElement])
         return @"";
 
     // Negative number
-    return stringToTimeTextAttributed(timeToString([_delegate mediaElement]->currentTime() - [_delegate mediaElement]->duration()), NSLeftTextAlignment);
+    return timeToString([_delegate mediaElement]->currentTime() - [_delegate mediaElement]->duration());
 }
 
 - (NSString *)elapsedTimeText
@@ -612,7 +608,7 @@ static NSString *stringToTimeTextAttributed(NSString *string, NSTextAlignment al
     if (![_delegate mediaElement])
         return @"";
 
-    return stringToTimeTextAttributed(timeToString([_delegate mediaElement]->currentTime()), NSRightTextAlignment);
+    return timeToString([_delegate mediaElement]->currentTime());
 }
 
 /*
index 50d4e19..605b37a 100644 (file)
@@ -1,3 +1,14 @@
+2009-11-02  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by John Sullivan.
+
+        WebKitSystemInterface part of making the appearance of the full-screen video HUD match
+        QuickTime Player X’s HUD.
+
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+        * libWebKitSystemInterfaceTiger.a:
+
 2009-10-26  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Adam Roben.
index 60c8017..630729b 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index a4b8ae7..a3b6420 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ
index 9ef1695..e2bc410 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceTiger.a and b/WebKitLibraries/libWebKitSystemInterfaceTiger.a differ