2010-09-09 Jer Noble <jer.noble@apple.com>
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Sep 2010 23:56:16 +0000 (23:56 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Sep 2010 23:56:16 +0000 (23:56 +0000)
        Reviewed by Eric Carlson.

        Adopt shared control drawing for <video> controls on Windows
        https://bugs.webkit.org/show_bug.cgi?id=45490

        * win/lib/WebKitSystemInterface.lib:
        * win/lib/WebKitSystemInterface_debug.lib:
2010-09-09  Jer Noble  <jer.noble@apple.com>

        Reviewed by Eric Carlson.

        Adopt shared control drawing for <video> controls on Windows
        https://bugs.webkit.org/show_bug.cgi?id=45490

        * DerivedSources.make: Remove the OS check around mediaControlsQuickTime.css.
        * rendering/RenderMediaControls.cpp:
        (WebCore::determineState): Use WKMediaControllerThemeState flags instead of SafariTheme ones.
        (WebCore::getUnzoomedRectAndAdjustCurrentContext): Added. Copied verbatim from RenderMediaMac.mm.
        (WebCore::RenderMediaControls::adjustMediaSliderThumbSize): Use wkMeasureMediaUIPart to adjust the thumb size.
        (WebCore::RenderMediaControls::paintMediaControlsPart): Use wkDrawMediaUIPart instead of paintThemePart.
        (WebCore::RenderMediaControls::volumeSliderOffsetFromMuteButton): Added. Copied verbatim from RenderMediaMac.mm.
        * rendering/RenderMediaControls.h:
        * rendering/RenderThemeWin.cpp:
        (WebCore::RenderThemeWin::adjustSliderThumbSize): Adjust both sliders and volume sliders.
        (WebCore::RenderThemeWin::extraMediaControlsStyleSheet): Added. Returns the mediaControlsQuickTime sheet.
        (WebCore::RenderThemeWin::paintMediaRewindButton): Added. Pass through to RenderMediaControls.
        (WebCore::RenderThemeWin::paintMediaControlsBackground): Added. Pass through to RenderMediaControls.
        (WebCore::RenderThemeWin::paintMediaVolumeSliderContainer): Added. Pass through to RenderMediaControls.
        (WebCore::RenderThemeWin::paintMediaVolumeSliderTrack): Added. Pass through to RenderMediaControls.
        (WebCore::RenderThemeWin::paintMediaVolumeSliderThumb): Added.  Pass through to RenderMediaControls.
        (WebCore::RenderThemeWin::volumeSliderOffsetFromMuteButton): Added. Pass through to RenderMediaControls.
        * rendering/RenderThemeWin.h:

2010-09-109  Peter Kasting  <pkasting@google.com>

        Reviewed by Darin Adler.

        Cleanup and simplification in advance of making middle clicks not send a
        click event.
        https://bugs.webkit.org/show_bug.cgi?id=22382

        * editing/DeleteButton.cpp:
        (WebCore::DeleteButton::defaultEventHandler): Removed unneeded code to
        check if the event is a MouseEvent. Any click event will do.
        * html/HTMLAnchorElement.cpp:
        (WebCore::appendServerMapMousePosition): Added. Factors out the
        modifications to the URL to add the mouse position to make the default
        event handler function easier to read.
        (WebCore::HTMLAnchorElement::defaultEventHandler): Reorganized to make
        the enter key logic separate from the link clicking logic and simplify
        the function.  This makes minor functional changes like not calling
        FrameLoader::urlSelected() for fake "keydown" events constructed from
        JavaScript.
        (WebCore::HTMLAnchorElement::isLiveLink): Refactored to use new shared
        implementation in treatLinkAsLiveForEventType().
        (WebCore::eventType): Factors out event type calculation (for
        treatLinkAsLiveForEventType()) from the default event handler to make it
        easier to read.
        (WebCore::HTMLAnchorElement::treatLinkAsLiveForEventType):
        Implementation of the portions of isLiveLink() that are common with the
        checks defaultEventHandler() wants to do.
        (WebCore::isEnterKeyKeydownEvent): Added. Shared by the default
        event handlers for all three anchor elements.
        (WebCore::isMiddleMouseButtonEvent): Added. Shared by the isLinkClick
        function below and some code in SVG. Later we can make this private to
        this source file once we remove the unneeded SVG code.
        (WebCore::isLinkClick): Added. Shared by the default event handlers for
        all three anchor elements.
        (WebCore::handleLinkClick): Ditto.
        * html/HTMLAnchorElement.h: Added the new functions.
        * svg/SVGAElement.cpp:
        (WebCore::SVGAElement::defaultEventHandler): Removed lots of unneeded
        logic and streamlined the code to more closely match the
        HTMLAnchorElement code and share functions with it.
        * wml/WMLAElement.cpp:
        (WebCore::WMLAElement::defaultEventHandler): Ditto.

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

17 files changed:
LayoutTests/platform/win/media/audio-controls-rendering-expected.txt
LayoutTests/platform/win/media/controls-after-reload-expected.txt
LayoutTests/platform/win/media/controls-strict-expected.txt
LayoutTests/platform/win/media/controls-styling-expected.txt
LayoutTests/platform/win/media/video-controls-rendering-expected.txt
LayoutTests/platform/win/media/video-display-toggle-expected.txt
LayoutTests/platform/win/media/video-no-audio-expected.txt
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/rendering/RenderMediaControls.cpp
WebCore/rendering/RenderMediaControls.h
WebCore/rendering/RenderThemeWin.cpp
WebCore/rendering/RenderThemeWin.h
WebKitLibraries/ChangeLog
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib
WebKitLibraries/win/lib/WebKitSystemInterface_debug.lib

index 77de6be813eade0906d5ec44bded00b4f0696e07..18e72b553ad425fc5df8647276065caf28ed8499 100644 (file)
@@ -21,7 +21,7 @@ layer at (8,42) size 200x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 136x16
       RenderSlider {INPUT} at (0,0) size 136x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (152,0) size 16x16
     RenderButton {INPUT} at (168,0) size 16x16
     RenderButton {INPUT} at (184,0) size 16x16
@@ -32,7 +32,7 @@ layer at (8,76) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -45,7 +45,7 @@ layer at (8,194) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index 59db57ac94caac9bf5fb512cc2858023bfd782ae..bf845b6551385e82866c63b47ca4339c313996f1 100644 (file)
@@ -17,7 +17,7 @@ layer at (8,266) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index 3bbf77dde28d3d542cd1751536848ec4e0366ae4..082c43013ee1f1d04760bbaee9c364c307809813 100644 (file)
@@ -17,7 +17,7 @@ layer at (8,274) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index f53f32e236c8aa1d913717f300331238097156d3..599f7f82023f008834fa77a60d8de5107c814277 100644 (file)
@@ -21,7 +21,7 @@ layer at (18,266) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -32,7 +32,7 @@ layer at (8,506) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index fff11e122c248c748c42b7c6a9f4e09e9507b92c..9deee0fc89037f66fa748be2cb86726eccd8d634 100644 (file)
@@ -22,7 +22,7 @@ layer at (8,266) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -33,7 +33,7 @@ layer at (8,506) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
@@ -46,7 +46,7 @@ layer at (8,746) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index 285d5454fc462239c29c7476f05de3aa208457b1..051f8d32351214a1e1adcf2e91919d0d676789a9 100644 (file)
@@ -16,7 +16,7 @@ layer at (8,250) size 320x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 256x16
       RenderSlider {INPUT} at (0,0) size 256x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (272,0) size 16x16
     RenderButton {INPUT} at (288,0) size 16x16
     RenderButton {INPUT} at (304,0) size 16x16
index 922f9f268c47f575c49c10050f0858c21d1629b7..f01dd1ac318f007d7319cd5e2d117f50426aba9c 100644 (file)
@@ -17,6 +17,6 @@ layer at (8,314) size 352x16
     RenderButton {INPUT} at (0,0) size 16x16
     RenderFlexibleBox {DIV} at (16,0) size 304x16
       RenderSlider {INPUT} at (0,0) size 304x16
-        RenderBlock {DIV} at (2,1) size 13x14
+        RenderBlock {DIV} at (2,4) size 10x8
     RenderButton {INPUT} at (320,0) size 16x16
     RenderButton {INPUT} at (336,0) size 16x16
index 1452c9d261e07525c2781c60eb3c338b666982b7..00ead9b2a3d943620cc5e334215864063ab86549 100644 (file)
@@ -1,3 +1,29 @@
+2010-09-09  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Adopt shared control drawing for <video> controls on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=45490
+        
+        * DerivedSources.make: Remove the OS check around mediaControlsQuickTime.css.
+        * rendering/RenderMediaControls.cpp:
+        (WebCore::determineState): Use WKMediaControllerThemeState flags instead of SafariTheme ones.
+        (WebCore::getUnzoomedRectAndAdjustCurrentContext): Added. Copied verbatim from RenderMediaMac.mm.
+        (WebCore::RenderMediaControls::adjustMediaSliderThumbSize): Use wkMeasureMediaUIPart to adjust the thumb size.
+        (WebCore::RenderMediaControls::paintMediaControlsPart): Use wkDrawMediaUIPart instead of paintThemePart.
+        (WebCore::RenderMediaControls::volumeSliderOffsetFromMuteButton): Added. Copied verbatim from RenderMediaMac.mm.
+        * rendering/RenderMediaControls.h:
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::adjustSliderThumbSize): Adjust both sliders and volume sliders.
+        (WebCore::RenderThemeWin::extraMediaControlsStyleSheet): Added. Returns the mediaControlsQuickTime sheet.
+        (WebCore::RenderThemeWin::paintMediaRewindButton): Added. Pass through to RenderMediaControls.
+        (WebCore::RenderThemeWin::paintMediaControlsBackground): Added. Pass through to RenderMediaControls.
+        (WebCore::RenderThemeWin::paintMediaVolumeSliderContainer): Added. Pass through to RenderMediaControls.
+        (WebCore::RenderThemeWin::paintMediaVolumeSliderTrack): Added. Pass through to RenderMediaControls.
+        (WebCore::RenderThemeWin::paintMediaVolumeSliderThumb): Added.  Pass through to RenderMediaControls.
+        (WebCore::RenderThemeWin::volumeSliderOffsetFromMuteButton): Added. Pass through to RenderMediaControls.
+        * rendering/RenderThemeWin.h:
+
 2010-09-109  Peter Kasting  <pkasting@google.com>
 
         Reviewed by Darin Adler.
index c37efb3481ba8c03668ba19a7828ac101e9d7cc4..ea301b86275ad0ed23888018cac54537173b38c6 100644 (file)
@@ -676,10 +676,8 @@ endif
 
 ifeq ($(findstring ENABLE_VIDEO,$(FEATURE_DEFINES)), ENABLE_VIDEO)
     USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/mediaControls.css
-ifeq ($(OS),MACOS)
     USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/mediaControlsQuickTime.css
 endif
-endif
 
 ifeq ($(findstring ENABLE_FULLSCREEN_API,$(FEATURE_DEFINES)), ENABLE_FULLSCREEN_API)
     USER_AGENT_STYLE_SHEETS := $(USER_AGENT_STYLE_SHEETS) $(WebCore)/css/fullscreen.css
index f75da7080a789bcc5858cae6af7726b86ef59e95..9c4757c07f7c6c930fdb9778f516c41cc2ceca12 100644 (file)
 #include "GraphicsContext.h"
 #include "HTMLMediaElement.h"
 #include "HTMLNames.h"
-#include "RenderThemeSafari.h"
-#include "SoftLinking.h"
+#include "RenderTheme.h"
 #include <CoreGraphics/CoreGraphics.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+
+#if PLATFORM(WIN)
+// The Windows version of WKSI defines these functions as capitalized, while the Mac version defines them as lower case.
+#define wkMediaControllerThemeAvailable(themeStyle) WKMediaControllerThemeAvailable(themeStyle)
+#define wkHitTestMediaUIPart(part, themeStyle, bounds, point) WKHitTestMediaUIPart(part, themeStyle, bounds, point)
+#define wkMeasureMediaUIPart(part, themeStyle, bounds, naturalSize) WKMeasureMediaUIPart(part, themeStyle, bounds, naturalSize)
+#define wkDrawMediaUIPart(part, themeStyle, context, rect, state) WKDrawMediaUIPart(part, themeStyle, context, rect, state)
+#define wkDrawMediaSliderTrack(themeStyle, context, rect, timeLoaded, currentTime, duration, state) WKDrawMediaSliderTrack(themeStyle, context, rect, timeLoaded, currentTime, duration, state)
+#endif
  
 using namespace std;
  
 namespace WebCore {
 
-#ifdef DEBUG_ALL
-SOFT_LINK_DEBUG_LIBRARY(SafariTheme)
-#else
-SOFT_LINK_LIBRARY(SafariTheme)
-#endif
-
-SOFT_LINK(SafariTheme, paintThemePart, void, __stdcall, (ThemePart part, CGContextRef context, const CGRect& rect, NSControlSize size, ThemeControlState state), (part, context, rect, size, state))
-SOFT_LINK(SafariTheme, STPaintProgressIndicator, void, APIENTRY, (ProgressIndicatorType type, CGContextRef context, const CGRect& rect, NSControlSize size, ThemeControlState state, float value), (type, context, rect, size, state, value))
-
 #if ENABLE(VIDEO)
 
-static ThemeControlState determineState(RenderObject* o)
+static WKMediaControllerThemeState determineState(RenderObject* o)
 {
-    ThemeControlState result = 0;
+    int result = 0;
     RenderTheme* theme = o->theme();
-    if (theme->isActive(o))
-        result |= SafariTheme::ActiveState;
-    if (theme->isEnabled(o) && !theme->isReadOnlyControl(o))
-        result |= SafariTheme::EnabledState;
+    if (!theme->isEnabled(o) || theme->isReadOnlyControl(o))
+        result |= WKMediaControllerFlagDisabled;
     if (theme->isPressed(o))
-        result |= SafariTheme::PressedState;
-    if (theme->isChecked(o))
-        result |= SafariTheme::CheckedState;
-    if (theme->isIndeterminate(o))
-        result |= SafariTheme::IndeterminateCheckedState;
+        result |= WKMediaControllerFlagPressed;
     if (theme->isFocused(o))
-        result |= SafariTheme::FocusedState;
-    if (theme->isDefault(o))
-        result |= SafariTheme::DefaultState;
-    return result;
+        result |= WKMediaControllerFlagFocused;
+    return static_cast<WKMediaControllerThemeState>(result);
+}
+
+// Utility to scale when the UI part are not scaled by wkDrawMediaUIPart
+static FloatRect getUnzoomedRectAndAdjustCurrentContext(RenderObject* o, const PaintInfo& paintInfo, const IntRect &originalRect)
+{
+    float zoomLevel = o->style()->effectiveZoom();
+    FloatRect unzoomedRect(originalRect);
+    if (zoomLevel != 1.0f) {
+        unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel);
+        unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel);
+        paintInfo.context->translate(unzoomedRect.x(), unzoomedRect.y());
+        paintInfo.context->scale(FloatSize(zoomLevel, zoomLevel));
+        paintInfo.context->translate(-unzoomedRect.x(), -unzoomedRect.y());
+    }
+    return unzoomedRect;
 }
 
 static const int mediaSliderThumbWidth = 13;
@@ -74,73 +81,78 @@ static const int mediaSliderThumbHeight = 14;
 
 void RenderMediaControls::adjustMediaSliderThumbSize(RenderObject* o)
 {
-    if (o->style()->appearance() != MediaSliderThumbPart)
+    ControlPart part = o->style()->appearance();
+
+    if (part != MediaSliderThumbPart && part != MediaVolumeSliderThumbPart)
         return;
 
+    CGSize size;
+    wkMeasureMediaUIPart(part == MediaSliderThumbPart ? MediaSliderThumb : MediaVolumeSliderThumb, WKMediaControllerThemeQuickTime, 0, &size);
+
     float zoomLevel = o->style()->effectiveZoom();
-    o->style()->setWidth(Length(static_cast<int>(mediaSliderThumbWidth * zoomLevel), Fixed));
-    o->style()->setHeight(Length(static_cast<int>(mediaSliderThumbHeight * zoomLevel), Fixed));
+    o->style()->setWidth(Length(static_cast<int>(size.width * zoomLevel), Fixed));
+    o->style()->setHeight(Length(static_cast<int>(size.height * zoomLevel), Fixed));
 }
 
 bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
-    ASSERT(SafariThemeLibrary());
-
+    static const int themeStyle = WKMediaControllerThemeQuickTime;
+    paintInfo.context->save();
     switch (part) {
         case MediaFullscreenButton:
-            paintThemePart(SafariTheme::MediaFullscreenButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+            wkDrawMediaUIPart(WKMediaUIPartFullscreenButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaShowClosedCaptionsButton:
         case MediaHideClosedCaptionsButton:
-#if SAFARI_THEME_VERSION >= 4
             if (MediaControlToggleClosedCaptionsButtonElement* btn = static_cast<MediaControlToggleClosedCaptionsButtonElement*>(o->node())) {
                 bool captionsVisible = btn->displayType() == MediaHideClosedCaptionsButton;
-                paintThemePart(captionsVisible ? SafariTheme::MediaHideClosedCaptionsButtonPart : SafariTheme::MediaShowClosedCaptionsButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+                wkDrawMediaUIPart(captionsVisible ? WKMediaUIPartHideClosedCaptionsButton : WKMediaUIPartShowClosedCaptionsButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             }
-#endif
             break;
         case MediaMuteButton:
         case MediaUnMuteButton:
             if (MediaControlMuteButtonElement* btn = static_cast<MediaControlMuteButtonElement*>(o->node())) {
                 bool audioEnabled = btn->displayType() == MediaMuteButton;
-                paintThemePart(audioEnabled ? SafariTheme::MediaMuteButtonPart : SafariTheme::MediaUnMuteButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+                wkDrawMediaUIPart(audioEnabled ? WKMediaUIPartMuteButton : WKMediaUIPartUnMuteButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             }
             break;
         case MediaPauseButton:
         case MediaPlayButton:
             if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(o->node())) {
                 bool canPlay = btn->displayType() == MediaPlayButton;
-                paintThemePart(canPlay ? SafariTheme::MediaPlayButtonPart : SafariTheme::MediaPauseButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+                wkDrawMediaUIPart(canPlay ? WKMediaUIPartPlayButton : WKMediaUIPartPauseButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             }
             break;
+        case MediaRewindButton:
+            wkDrawMediaUIPart(WKMediaUIPartRewindButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
+            break;
         case MediaSeekBackButton:
-            paintThemePart(SafariTheme::MediaSeekBackButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+            wkDrawMediaUIPart(WKMediaUIPartSeekBackButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaSeekForwardButton:
-            paintThemePart(SafariTheme::MediaSeekForwardButtonPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+            wkDrawMediaUIPart(WKMediaUIPartSeekForwardButton, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaSlider: {
-            if (HTMLMediaElement* mediaElement = toParentMediaElement(o))
-                STPaintProgressIndicator(SafariTheme::MediaType, paintInfo.context->platformContext(), r, NSRegularControlSize, 0, mediaElement->percentLoaded());
+            if (HTMLMediaElement* mediaElement = toParentMediaElement(o)) {
+                FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo, r);
+                wkDrawMediaSliderTrack(themeStyle, paintInfo.context->platformContext(), unzoomedRect, mediaElement->percentLoaded() * mediaElement->duration(), mediaElement->currentTime(), mediaElement->duration(), determineState(o));
+            }
             break;
         }
         case MediaSliderThumb:
-            paintThemePart(SafariTheme::MediaSliderThumbPart, paintInfo.context->platformContext(), r, NSRegularControlSize, determineState(o));
+            wkDrawMediaUIPart(WKMediaUIPartTimelineSliderThumb, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaVolumeSliderContainer:
-            // FIXME: Implement volume slider.
-            ASSERT_NOT_REACHED();
+            wkDrawMediaUIPart(WKMediaUIPartVolumeSliderContainer, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaVolumeSlider:
-            // FIXME: Implement volume slider.
-            ASSERT_NOT_REACHED();
+            wkDrawMediaUIPart(WKMediaUIPartVolumeSlider, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaVolumeSliderThumb:
-            // FIXME: Implement volume slider.
-            ASSERT_NOT_REACHED();
+            wkDrawMediaUIPart(WKMediaUIPartVolumeSliderThumb, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaTimelineContainer:
-            ASSERT_NOT_REACHED();
+            wkDrawMediaUIPart(WKMediaUIPartBackground, themeStyle, paintInfo.context->platformContext(), r, determineState(o));
             break;
         case MediaCurrentTimeDisplay:
             ASSERT_NOT_REACHED();
@@ -152,9 +164,24 @@ bool RenderMediaControls::paintMediaControlsPart(MediaControlElementType part, R
             ASSERT_NOT_REACHED();
             break;
     }
+    paintInfo.context->restore();
+
     return false;
 }
 
+IntPoint RenderMediaControls::volumeSliderOffsetFromMuteButton(Node* muteButton, const IntSize& size)
+{
+    static const int xOffset = -4;
+    static const int yOffset = 5;
+
+    float zoomLevel = muteButton->renderer()->style()->effectiveZoom();
+    int y = yOffset * zoomLevel + muteButton->renderBox()->offsetHeight() - size.height();
+    FloatPoint absPoint = muteButton->renderer()->localToAbsolute(FloatPoint(muteButton->renderBox()->offsetLeft(), y), true, true);
+    if (absPoint.y() < 0)
+        y = muteButton->renderBox()->height();
+    return IntPoint(xOffset * zoomLevel, y);
+
+}
 #endif  // #if ENABLE(VIDEO)
 
 } // namespace WebCore
index 9683dd73db979cc215735647f94f456c6ba0f431..f05c54933f84f7e2ad0e34ce196dace412c38743 100644 (file)
@@ -36,6 +36,7 @@ class RenderMediaControls {
 public:
     static bool paintMediaControlsPart(MediaControlElementType, RenderObject*, const PaintInfo&, const IntRect&);
     static void adjustMediaSliderThumbSize(RenderObject*);
+    static IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&);
 };
 
 } // namespace WebCore
index 8a3317364a0f4b174946733518068fdf566bcd18..b4fb8eb21e0360c07a010ce75f2d9a0616983961 100644 (file)
@@ -749,15 +749,16 @@ const int sliderThumbHeight = 15;
 
 void RenderThemeWin::adjustSliderThumbSize(RenderObject* o) const
 {
-    if (o->style()->appearance() == SliderThumbVerticalPart) {
+    ControlPart part = o->style()->appearance();
+    if (part == SliderThumbVerticalPart) {
         o->style()->setWidth(Length(sliderThumbHeight, Fixed));
         o->style()->setHeight(Length(sliderThumbWidth, Fixed));
-    } else if (o->style()->appearance() == SliderThumbHorizontalPart) {
+    } else if (part == SliderThumbHorizontalPart) {
         o->style()->setWidth(Length(sliderThumbWidth, Fixed));
         o->style()->setHeight(Length(sliderThumbHeight, Fixed));
     }
 #if ENABLE(VIDEO)
-    else if (o->style()->appearance() == MediaSliderThumbPart) 
+    else if (part == MediaSliderThumbPart || part == MediaVolumeSliderThumbPart) 
         RenderMediaControls::adjustMediaSliderThumbSize(o);
 #endif
 }
@@ -937,6 +938,11 @@ Color RenderThemeWin::systemColor(int cssValueId) const
 
 #if ENABLE(VIDEO)
 
+String RenderThemeWin::extraMediaControlsStyleSheet()
+{
+    return String(mediaControlsQuickTimeUserAgentStyleSheet, sizeof(mediaControlsQuickTimeUserAgentStyleSheet));
+}
+
 bool RenderThemeWin::shouldRenderMediaControlPart(ControlPart part, Element* element)
 {
     if (part == MediaToggleClosedCaptionsButtonPart) {
@@ -968,6 +974,11 @@ bool RenderThemeWin::paintMediaPlayButton(RenderObject* o, const PaintInfo& pain
     return RenderMediaControls::paintMediaControlsPart(MediaPlayButton, o, paintInfo, r);
 }
 
+bool RenderThemeWin::paintMediaRewindButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+    return RenderMediaControls::paintMediaControlsPart(MediaRewindButton, o, paintInfo, r);
+}
+
 bool RenderThemeWin::paintMediaSeekBackButton(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
 {
     return RenderMediaControls::paintMediaControlsPart(MediaSeekBackButton, o, paintInfo, r);
@@ -993,6 +1004,32 @@ bool RenderThemeWin::paintMediaToggleClosedCaptionsButton(RenderObject* o, const
     return RenderMediaControls::paintMediaControlsPart(MediaShowClosedCaptionsButton, o, paintInfo, r);
 }
 
+bool RenderThemeWin::paintMediaControlsBackground(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+    return RenderMediaControls::paintMediaControlsPart(MediaTimelineContainer, o, paintInfo, r);
+}
+
+bool RenderThemeWin::paintMediaVolumeSliderContainer(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+    return RenderMediaControls::paintMediaControlsPart(MediaVolumeSliderContainer, o, paintInfo, r);
+}
+
+bool RenderThemeWin::paintMediaVolumeSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+    return RenderMediaControls::paintMediaControlsPart(MediaVolumeSlider, o, paintInfo, r);
+}
+
+bool RenderThemeWin::paintMediaVolumeSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
+{
+    return RenderMediaControls::paintMediaControlsPart(MediaVolumeSliderThumb, o, paintInfo, r);
+}
+
+IntPoint RenderThemeWin::volumeSliderOffsetFromMuteButton(Node* muteButton, const IntSize& size) const
+{
+    return RenderMediaControls::volumeSliderOffsetFromMuteButton(muteButton, size);
+}
+
+
 #endif
 
 }
index 0147900efd965e8c1955006cc18cff8c28eb84e2..1efb117e6bbfd8d659ac226dcf618485bbc86cd0 100644 (file)
@@ -120,15 +120,22 @@ public:
     virtual bool supportsFocusRing(const RenderStyle*) const;
 
 #if ENABLE(VIDEO)
+    virtual String extraMediaControlsStyleSheet();
     virtual bool shouldRenderMediaControlPart(ControlPart, Element*);
+    virtual bool paintMediaControlsBackground(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaFullscreenButton(RenderObject*, const PaintInfo&, const IntRect&);
-    virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaMuteButton(RenderObject*, const PaintInfo&, const IntRect&);
+    virtual bool paintMediaPlayButton(RenderObject*, const PaintInfo&, const IntRect&);
+    virtual bool paintMediaRewindButton(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaSeekBackButton(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaSeekForwardButton(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
     virtual bool paintMediaToggleClosedCaptionsButton(RenderObject*, const PaintInfo&, const IntRect&);
+    virtual bool paintMediaVolumeSliderContainer(RenderObject*, const PaintInfo&, const IntRect&);
+    virtual bool paintMediaVolumeSliderTrack(RenderObject*, const PaintInfo&, const IntRect&);
+    virtual bool paintMediaVolumeSliderThumb(RenderObject*, const PaintInfo&, const IntRect&);
+    virtual IntPoint volumeSliderOffsetFromMuteButton(Node*, const IntSize&) const;
 #endif
 
 private:
index e1e53e62ba73a15feca3c2037b9954c046f372dc..5a0cf49861e0e6acbaaff2ec103a277d10df8912 100644 (file)
@@ -1,3 +1,13 @@
+2010-09-09  Jer Noble  <jer.noble@apple.com>
+
+        Reviewed by Eric Carlson.
+
+        Adopt shared control drawing for <video> controls on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=45490
+
+        * win/lib/WebKitSystemInterface.lib:
+        * win/lib/WebKitSystemInterface_debug.lib:
+
 2010-09-10  Anders Carlsson  <andersca@apple.com>
 
         WebKitSystemInterface part of:
index 445b292aee8a071bfe26517e8247a5cf70362be6..80830a738f665ba4f9cfca84aad27b9d31199086 100644 (file)
@@ -28,6 +28,7 @@
 
 struct CGAffineTransform;
 struct CGPoint;
+struct CGRect;
 struct CGSize;
 
 typedef const struct __CFData* CFDataRef;
@@ -89,4 +90,46 @@ CFURLCredentialRef wkCopyCredentialFromCFPersistentStorage(CFURLProtectionSpaceR
 
 CFStringRef wkCFNetworkErrorGetLocalizedDescription(CFIndex errorCode);
 
+typedef enum {
+    WKMediaUIPartFullscreenButton   = 0,
+    WKMediaUIPartMuteButton,
+    WKMediaUIPartPlayButton,
+    WKMediaUIPartSeekBackButton,
+    WKMediaUIPartSeekForwardButton,
+    WKMediaUIPartTimelineSlider,
+    WKMediaUIPartTimelineSliderThumb,
+    WKMediaUIPartRewindButton,
+    WKMediaUIPartSeekToRealtimeButton,
+    WKMediaUIPartShowClosedCaptionsButton,
+    WKMediaUIPartHideClosedCaptionsButton,
+    WKMediaUIPartUnMuteButton,
+    WKMediaUIPartPauseButton,
+    WKMediaUIPartBackground,
+    WKMediaUIPartCurrentTimeDisplay,
+    WKMediaUIPartTimeRemainingDisplay,
+    WKMediaUIPartStatusDisplay,
+    WKMediaUIPartControlsPanel,
+    WKMediaUIPartVolumeSliderContainer,
+    WKMediaUIPartVolumeSlider,
+    WKMediaUIPartVolumeSliderThumb
+} WKMediaUIPart;
+
+typedef enum {
+    WKMediaControllerThemeClassic   = 1,
+    WKMediaControllerThemeQuickTime = 2
+} WKMediaControllerThemeStyle;
+
+typedef enum {
+    WKMediaControllerFlagDisabled = 1 << 0,
+    WKMediaControllerFlagPressed = 1 << 1,
+    WKMediaControllerFlagDrawEndCaps = 1 << 3,
+    WKMediaControllerFlagFocused = 1 << 4
+} WKMediaControllerThemeState;
+
+bool WKMediaControllerThemeAvailable(int themeStyle);
+bool WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point);
+void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
+void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
+void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
+
 #endif // WebKitSystemInterface_h
index 4fcc36bd343a78c73bb30c49b33d85ec38ccfc60..40513e628c13aa7f7d0494117685ddc7f6d07488 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ
index 6d836db135873d8adecb6c48244ad427abb841eb..124c2419db5552559daa1708fcbf47eac32e9ffe 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface_debug.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface_debug.lib differ