Changeset 47756 in webkit


Ignore:
Timestamp:
Aug 25, 2009 1:40:16 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-25 Alpha Lam <hclam@chromium.org>

Reviewed by David Levin.

[chromium] Implement media volume slider for chromium
https://bugs.webkit.org/show_bug.cgi?id=28715

Provided the implementation of the volume slider and its container for
chromium port. With this change there will be a usable volume control
slider for chromium theme.

No new tests since this is covered by existing media layout tests.

  • css/mediaControlsChromium.css: CSS style for the volume slider.
  • rendering/RenderThemeChromiumSkia.cpp: (WebCore::mediaSliderThumbImage): Returns the image for slider thumb. (WebCore::mediaVolumeSliderThumbImage): Returns the image for volume slider thumb. (WebCore::RenderThemeChromiumSkia::paintMediaVolumeSliderTrack): Paints the track with one vertical white line. (WebCore::RenderThemeChromiumSkia::adjustSliderThumbSize): Adjusts thumb sizes according to the images. (WebCore::RenderThemeChromiumSkia::paintMediaSliderThumb): Paints slider thumb image. (WebCore::RenderThemeChromiumSkia::paintMediaVolumeSliderThumb): Paints volume slider thumb image.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47754 r47756  
     12009-08-25  Alpha Lam  <hclam@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        [chromium] Implement media volume slider for chromium
     6        https://bugs.webkit.org/show_bug.cgi?id=28715
     7
     8        Provided the implementation of the volume slider and its container for
     9        chromium port. With this change there will be a usable volume control
     10        slider for chromium theme.
     11
     12        No new tests since this is covered by existing media layout tests.
     13
     14        * css/mediaControlsChromium.css: CSS style for the volume slider.
     15        * rendering/RenderThemeChromiumSkia.cpp:
     16        (WebCore::mediaSliderThumbImage): Returns the image for slider thumb.
     17        (WebCore::mediaVolumeSliderThumbImage): Returns the image for volume slider thumb.
     18        (WebCore::RenderThemeChromiumSkia::paintMediaVolumeSliderTrack): Paints the track with one vertical white line.
     19        (WebCore::RenderThemeChromiumSkia::adjustSliderThumbSize): Adjusts thumb sizes according to the images.
     20        (WebCore::RenderThemeChromiumSkia::paintMediaSliderThumb): Paints slider thumb image.
     21        (WebCore::RenderThemeChromiumSkia::paintMediaVolumeSliderThumb): Paints volume slider thumb image.
     22
    1232009-08-25  Chris Marrin  <cmarrin@apple.com>
    224
  • trunk/WebCore/css/mediaControlsChromium.css

    r46740 r47756  
    3434    -webkit-user-select: none;
    3535    position: absolute;
     36    overflow: visible;
    3637    bottom: 0;
    3738    width: 100%;
     
    4748audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button {
    4849    -webkit-appearance: media-mute-button;
    49 
    5050    position: absolute;
    5151    top: auto;
     
    168168    display: none;
    169169}
     170
     171audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container {
     172    -webkit-appearance: media-volume-slider-container;
     173    position: absolute;
     174
     175    width: 34px;
     176    height: 100px;
     177
     178    background-color: rgba(0, 0, 0, 0.6);
     179}
     180
     181audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider {
     182    -webkit-appearance: media-volume-slider;
     183    display: inline;
     184    position: absolute;
     185
     186    top: 10px;
     187    left: 12px;
     188
     189    width: 10px;
     190    height: 80px;
     191}
  • trunk/WebCore/rendering/RenderThemeChromiumSkia.cpp

    r47576 r47756  
    572572}
    573573
    574 void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderObject* object) const {
    575 #if ENABLE(VIDEO)
    576     if (object->style()->appearance() == MediaSliderThumbPart) {
    577         static Image* mediaSliderThumb = Image::loadPlatformResource("mediaSliderThumb").releaseRef();
    578 
    579         object->style()->setWidth(Length(mediaSliderThumb->width(), Fixed));
    580         object->style()->setHeight(Length(mediaSliderThumb->height(), Fixed));
    581     }
     574bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
     575{
     576#if ENABLE(VIDEO)
     577    HTMLMediaElement* mediaElement = mediaElementParent(object->node());
     578    if (!mediaElement)
     579        return false;
     580
     581    SkCanvas* canvas = paintInfo.context->platformContext()->canvas();
     582    SkPaint paint;
     583    paint.setARGB(0xff, 0xff, 0xff, 0xff);
     584
     585    int x = rect.x() + rect.width() / 2;
     586    canvas->drawLine(x, rect.y(), x, rect.y() + rect.height(), paint);
     587    return true;
    582588#else
    583589    UNUSED_PARAM(object);
     590    UNUSED_PARAM(paintInfo);
     591    UNUSED_PARAM(rect);
     592    return false;
     593#endif
     594}
     595
     596static Image* mediaSliderThumbImage()
     597{
     598    static Image* mediaSliderThumb = Image::loadPlatformResource("mediaSliderThumb").releaseRef();
     599    return mediaSliderThumb;
     600}
     601
     602static Image* mediaVolumeSliderThumbImage()
     603{
     604    static Image* mediaVolumeSliderThumb = Image::loadPlatformResource("mediaVolumeSliderThumb").releaseRef();
     605    return mediaVolumeSliderThumb;
     606}
     607
     608void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderObject* object) const
     609{
     610#if ENABLE(VIDEO)
     611    Image* thumbImage = 0;
     612    if (object->style()->appearance() == MediaSliderThumbPart)
     613        thumbImage = mediaSliderThumbImage();
     614    else if (object->style()->appearance() == MediaVolumeSliderThumbPart)
     615        thumbImage = mediaVolumeSliderThumbImage();
     616
     617    ASSERT(thumbImage);
     618    object->style()->setWidth(Length(thumbImage->width(), Fixed));
     619    object->style()->setHeight(Length(thumbImage->height(), Fixed));
     620#else
     621    UNUSED_PARAM(object);
    584622#endif
    585623}
     
    591629        return false;
    592630
    593     static Image* mediaSliderThumb = Image::loadPlatformResource("mediaSliderThumb").releaseRef();
    594 
    595     return paintMediaButtonInternal(paintInfo.context, rect, mediaSliderThumb);
     631    return paintMediaButtonInternal(paintInfo.context, rect, mediaSliderThumbImage());
     632#else
     633    UNUSED_PARAM(object);
     634    UNUSED_PARAM(paintInfo);
     635    UNUSED_PARAM(rect);
     636    return false;
     637#endif
     638}
     639
     640bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
     641{
     642#if ENABLE(VIDEO)
     643    if (!object->parent()->isSlider())
     644        return false;
     645
     646    return paintMediaButtonInternal(paintInfo.context, rect, mediaVolumeSliderThumbImage());
    596647#else
    597648    UNUSED_PARAM(object);
  • trunk/WebCore/rendering/RenderThemeChromiumSkia.h

    r46740 r47756  
    9292        virtual bool paintMediaControlsBackground(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    9393        virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     94        virtual bool paintMediaVolumeSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    9495        virtual void adjustSliderThumbSize(RenderObject*) const;
    9596        virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
     97        virtual bool paintMediaVolumeSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    9698        virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
    9799        virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
Note: See TracChangeset for help on using the changeset viewer.