Changeset 45572 in webkit


Ignore:
Timestamp:
Jul 6, 2009 3:56:34 PM (15 years ago)
Author:
eric.carlson@apple.com
Message:

2009-07-06 Eric Carlson <eric.carlson@apple.com>

Reviewed by Darin Adler.

<rdar://problem/7008093> Media controller can’t be used to scrub when movie is
narrow — track is too narrow

Do not show media controller time display elements when the a movie is too narrow.

  • platform/mac/WebCoreSystemInterface.h:
  • platform/mac/WebCoreSystemInterface.mm:

The 'state' parameter to wkDrawMediaUIPart is now an unsigned bitfield.

  • rendering/MediaControlElements.cpp: (WebCore::MediaControlTimeDisplayElement::MediaControlTimeDisplayElement):

Give current time and time remaining controls a common base class.

(WebCore::MediaControlTimeDisplayElement::setVisible):

New method, hide and show the element.

  • rendering/MediaControlElements.h:
  • rendering/RenderMedia.cpp: (WebCore::RenderMedia::RenderMedia):

Initialize m_previousVisible.

(WebCore::RenderMedia::layout):

Show/hide the time display elements as the movie width changes.

(WebCore::RenderMedia::createCurrentTimeDisplay):
(WebCore::RenderMedia::createTimeRemainingDisplay):

Base class is now MediaControlTimeDisplayElement, not MediaControlElement.

(WebCore::RenderMedia::shouldShowTimeDisplayControls):

New, decide if time display elements should be visible or not.

  • rendering/RenderMedia.h:
  • rendering/RenderThemeMac.mm: (WebCore::): (WebCore::RenderThemeMac::paintMediaFullscreenButton): (WebCore::RenderThemeMac::paintMediaMuteButton): (WebCore::RenderThemeMac::paintMediaPlayButton): (WebCore::RenderThemeMac::paintMediaSeekBackButton): (WebCore::RenderThemeMac::paintMediaSeekForwardButton): (WebCore::RenderThemeMac::paintMediaSliderTrack): (WebCore::RenderThemeMac::paintMediaSliderThumb): (WebCore::RenderThemeMac::paintMediaRewindButton): (WebCore::RenderThemeMac::paintMediaReturnToRealtimeButton): (WebCore::RenderThemeMac::paintMediaControlsBackground): (WebCore::RenderThemeMac::paintMediaCurrentTime): (WebCore::RenderThemeMac::paintMediaTimeRemaining):

The 'state' parameter to wkDrawMediaUIPart is now an unsigned bitfield.

2009-07-06 Eric Carlson <eric.carlson@apple.com>

Update WebKitSystemInterface for <rdar://problem/7008093>.

  • WebKitSystemInterface.h:
  • libWebKitSystemInterfaceLeopard.a:
  • libWebKitSystemInterfaceSnowLeopard.a:
  • libWebKitSystemInterfaceTiger.a:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r45571 r45572  
     12009-07-06  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7008093> Media controller can’t be used to scrub when movie is
     6        narrow — track is too narrow
     7
     8        Do not show media controller time display elements when the a movie is too narrow.
     9
     10        * platform/mac/WebCoreSystemInterface.h:
     11        * platform/mac/WebCoreSystemInterface.mm:
     12            The 'state' parameter to wkDrawMediaUIPart is now an unsigned bitfield.
     13
     14        * rendering/MediaControlElements.cpp:
     15        (WebCore::MediaControlTimeDisplayElement::MediaControlTimeDisplayElement):
     16            Give current time and time remaining controls a common base class.
     17        (WebCore::MediaControlTimeDisplayElement::setVisible):
     18            New method, hide and show the element.
     19        * rendering/MediaControlElements.h:
     20
     21        * rendering/RenderMedia.cpp:
     22        (WebCore::RenderMedia::RenderMedia):
     23            Initialize m_previousVisible.
     24        (WebCore::RenderMedia::layout):
     25            Show/hide the time display elements as the movie width changes.
     26        (WebCore::RenderMedia::createCurrentTimeDisplay):
     27        (WebCore::RenderMedia::createTimeRemainingDisplay):
     28            Base class is now MediaControlTimeDisplayElement, not MediaControlElement.
     29        (WebCore::RenderMedia::shouldShowTimeDisplayControls):
     30            New, decide if time display elements should be visible or not.
     31        * rendering/RenderMedia.h:
     32
     33        * rendering/RenderThemeMac.mm:
     34        (WebCore::):
     35        (WebCore::RenderThemeMac::paintMediaFullscreenButton):
     36        (WebCore::RenderThemeMac::paintMediaMuteButton):
     37        (WebCore::RenderThemeMac::paintMediaPlayButton):
     38        (WebCore::RenderThemeMac::paintMediaSeekBackButton):
     39        (WebCore::RenderThemeMac::paintMediaSeekForwardButton):
     40        (WebCore::RenderThemeMac::paintMediaSliderTrack):
     41        (WebCore::RenderThemeMac::paintMediaSliderThumb):
     42        (WebCore::RenderThemeMac::paintMediaRewindButton):
     43        (WebCore::RenderThemeMac::paintMediaReturnToRealtimeButton):
     44        (WebCore::RenderThemeMac::paintMediaControlsBackground):
     45        (WebCore::RenderThemeMac::paintMediaCurrentTime):
     46        (WebCore::RenderThemeMac::paintMediaTimeRemaining):
     47            The 'state' parameter to wkDrawMediaUIPart is now an unsigned bitfield.
     48
    1492009-07-06  David Kilzer  <ddkilzer@apple.com>
    250
  • trunk/WebCore/platform/mac/WebCoreSystemInterface.h

    r45565 r45572  
    105105extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
    106106extern BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
    107 extern void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration);
    108 extern void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, int state);
     107extern void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime,
     108    float duration, unsigned state);
     109extern void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
    109110extern NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
    110111extern NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
  • trunk/WebCore/platform/mac/WebCoreSystemInterface.mm

    r45565 r45572  
    4040NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
    4141BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
    42 void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration);
     42void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime,
     43    float duration, unsigned state);
    4344BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point);
    44 void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, int state);
     45void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
    4546void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
    4647NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
  • trunk/WebCore/rendering/MediaControlElements.cpp

    r45518 r45572  
    471471// ----------------------------
    472472
     473MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(Document* doc, PseudoId pseudo, HTMLMediaElement* element)
     474    : MediaControlElement(doc, pseudo, element)
     475    , m_cachedWidth(Length(0, Fixed))
     476{
     477}
     478
     479void MediaControlTimeDisplayElement::setVisible(bool visible)
     480{
     481    if (!renderer() || !renderer()->style())
     482        return;
     483
     484    if (!m_cachedWidth.value()) {
     485        RenderStyle* style = m_mediaElement->renderer()->getCachedPseudoStyle(m_pseudoStyleId);
     486        if (!style)
     487            return;
     488        m_cachedWidth = style->width();
     489    }
     490
     491    renderer()->style()->setWidth(visible ? m_cachedWidth : Length(0, Fixed));
     492}
     493
     494
    473495} //namespace WebCore
    474496#endif // enable(video)
  • trunk/WebCore/rendering/MediaControlElements.h

    r45474 r45572  
    201201// ----------------------------
    202202
     203class MediaControlTimeDisplayElement : public MediaControlElement {
     204public:
     205    MediaControlTimeDisplayElement(Document*, PseudoId, HTMLMediaElement*);
     206    void setVisible(bool);
     207private:
     208    Length m_cachedWidth;
     209};
     210
     211// ----------------------------
     212
    203213class RenderMediaControlShadowRoot : public RenderBlock {
    204214public:
     
    208218   
    209219// ----------------------------
     220
    210221
    211222} //namespace WebCore
  • trunk/WebCore/rendering/RenderMedia.cpp

    r45474 r45572  
    6868    , m_opacityAnimationFrom(0)
    6969    , m_opacityAnimationTo(1.0f)
     70    , m_previousVisible(VISIBLE)
    7071{
    7172}
     
    132133    IntSize newSize = contentBoxRect().size();
    133134    if (newSize != oldSize || controlsRenderer->needsLayout()) {
     135
     136        if (m_currentTimeDisplay && m_timeRemainingDisplay) {
     137            bool shouldShowTimeDisplays = shouldShowTimeDisplayControls();
     138            m_currentTimeDisplay->setVisible(shouldShowTimeDisplays);
     139            m_timeRemainingDisplay->setVisible(shouldShowTimeDisplays);
     140        }
     141
    134142        controlsRenderer->setLocation(borderLeft() + paddingLeft(), borderTop() + paddingTop());
    135143        controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed));
     
    222230{
    223231    ASSERT(!m_currentTimeDisplay);
    224     m_currentTimeDisplay = new MediaControlElement(document(), MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, mediaElement());
     232    m_currentTimeDisplay = new MediaControlTimeDisplayElement(document(), MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, mediaElement());
    225233    m_currentTimeDisplay->attachToParent(m_timelineContainer.get());
    226234}
     
    229237{
    230238    ASSERT(!m_timeRemainingDisplay);
    231     m_timeRemainingDisplay = new MediaControlElement(document(), MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, mediaElement());
     239    m_timeRemainingDisplay = new MediaControlTimeDisplayElement(document(), MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, mediaElement());
    232240    m_timeRemainingDisplay->attachToParent(m_timelineContainer.get());
    233241}
     
    498506}
    499507
     508
     509// We want the timeline slider to be at least 100 pixels wide.
     510static const int minWidthToDisplayTimeDisplays = 16 + 16 + 45 + 100 + 45 + 16 + 1;
     511
     512bool RenderMedia::shouldShowTimeDisplayControls() const
     513{
     514    if (!m_currentTimeDisplay && !m_timeRemainingDisplay)
     515        return false;
     516
     517    int width = mediaElement()->renderBox()->width();
     518    return width >= minWidthToDisplayTimeDisplays;
     519}
     520
    500521} // namespace WebCore
    501522
  • trunk/WebCore/rendering/RenderMedia.h

    r45474 r45572  
    7272    static String formatTime(float time);
    7373
     74    bool shouldShowTimeDisplayControls() const;
     75
    7476    void updateFromElement();
    7577    void updatePlayer();
     
    119121    RefPtr<MediaControlFullscreenButtonElement> m_fullscreenButton;
    120122    RefPtr<MediaControlTimelineContainerElement> m_timelineContainer;
    121     RefPtr<MediaControlElement> m_currentTimeDisplay;
    122     RefPtr<MediaControlElement> m_timeRemainingDisplay;
     123    RefPtr<MediaControlTimeDisplayElement> m_currentTimeDisplay;
     124    RefPtr<MediaControlTimeDisplayElement> m_timeRemainingDisplay;
    123125    RefPtr<MediaControlStatusDisplayElement> m_statusDisplay;
    124126    RenderObjectChildList m_children;
  • trunk/WebCore/rendering/RenderThemeMac.mm

    r45569 r45572  
    3535#import "LocalCurrentGraphicsContext.h"
    3636#import "MediaControlElements.h"
     37#import "RenderMedia.h"
    3738#import "RenderSlider.h"
    3839#import "RenderView.h"
     
    14781479#if ENABLE(VIDEO)
    14791480
     1481enum WKMediaControllerThemeState {
     1482    MediaUIPartDisbledFlag = 1 << 0,
     1483    MediaUIPartPressedFlag = 1 << 1,
     1484    MediaUIPartDrawEndCapsFlag = 1 << 3,
     1485};
     1486
     1487
    14801488// Utility to scale when the UI part are not scaled by wkDrawMediaUIPart
    14811489static FloatRect getUnzoomedRectAndAdjustCurrentContext(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect &originalRect)
     
    14931501}
    14941502
     1503
    14951504bool RenderThemeMac::paintMediaFullscreenButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
    14961505{
     
    15001509
    15011510    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1502     wkDrawMediaUIPart(MediaFullscreenButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
     1511    wkDrawMediaUIPart(MediaFullscreenButton, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1512        node->active() ? MediaUIPartPressedFlag : 0);
    15031513    return false;
    15041514}
     
    15131523    if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) {
    15141524        LocalCurrentGraphicsContext localContext(paintInfo.context);
    1515         wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
     1525        wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1526            node->active() ? MediaUIPartPressedFlag : 0);
     1527
    15161528    }
    15171529    return false;
     
    15271539    if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) {
    15281540        LocalCurrentGraphicsContext localContext(paintInfo.context);
    1529         wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
     1541        wkDrawMediaUIPart(btn->displayType(), mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1542            node->active() ? MediaUIPartPressedFlag : 0);
    15301543    }
    15311544    return false;
     
    15391552
    15401553    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1541     wkDrawMediaUIPart(MediaSeekBackButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
    1542     return false;
     1554    wkDrawMediaUIPart(MediaSeekBackButton, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1555        node->active() ? MediaUIPartPressedFlag : 0);
     1556     return false;
    15431557}
    15441558
     
    15501564
    15511565    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1552     wkDrawMediaUIPart(MediaSeekForwardButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
    1553     return false;
     1566    wkDrawMediaUIPart(MediaSeekForwardButton, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1567        node->active() ? MediaUIPartPressedFlag : 0);
     1568     return false;
    15541569}
    15551570
     
    15761591    paintInfo.context->save();
    15771592    FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo, r);
    1578     wkDrawMediaSliderTrack(mediaControllerTheme(), paintInfo.context->platformContext(), unzoomedRect, timeLoaded, currentTime, duration);
     1593    bool shouldDrawEndCaps = !static_cast<RenderMedia*>(mediaElement->renderer())->shouldShowTimeDisplayControls();
     1594    wkDrawMediaSliderTrack(mediaControllerTheme(), paintInfo.context->platformContext(), unzoomedRect,
     1595        timeLoaded, currentTime, duration, shouldDrawEndCaps ? MediaUIPartDrawEndCapsFlag : 0);
    15791596    paintInfo.context->restore();
    15801597    return false;
     
    15881605
    15891606    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1590     wkDrawMediaUIPart(MediaSliderThumb, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
    1591     return false;
     1607    wkDrawMediaUIPart(MediaSliderThumb, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1608        node->active() ? MediaUIPartPressedFlag : 0);
     1609     return false;
    15921610}
    15931611   
     
    15991617   
    16001618    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1601     wkDrawMediaUIPart(MediaRewindButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
    1602     return false;
     1619    wkDrawMediaUIPart(MediaRewindButton, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1620        node->active() ? MediaUIPartPressedFlag : 0);
     1621     return false;
    16031622}
    16041623
     
    16101629   
    16111630    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1612     wkDrawMediaUIPart(MediaReturnToRealtimeButton, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
    1613     return false;
     1631    wkDrawMediaUIPart(MediaReturnToRealtimeButton, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1632        node->active() ? MediaUIPartPressedFlag : 0);
     1633     return false;
    16141634}
    16151635
     
    16221642
    16231643    LocalCurrentGraphicsContext localContext(paintInfo.context);
    1624     wkDrawMediaUIPart(MediaTimelineContainer, mediaControllerTheme(), paintInfo.context->platformContext(), r, node->active());
    1625     return false;
     1644    wkDrawMediaUIPart(MediaTimelineContainer, mediaControllerTheme(), paintInfo.context->platformContext(), r,
     1645        node->active() ? MediaUIPartPressedFlag : 0);
     1646     return false;
    16261647}
    16271648
     
    16341655    paintInfo.context->save();
    16351656    FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo, r);
    1636     wkDrawMediaUIPart(MediaCurrentTimeDisplay, mediaControllerTheme(), paintInfo.context->platformContext(), unzoomedRect, node->active());
     1657    wkDrawMediaUIPart(MediaCurrentTimeDisplay, mediaControllerTheme(), paintInfo.context->platformContext(), unzoomedRect,
     1658        node->active() ? MediaUIPartPressedFlag : 0);
    16371659    paintInfo.context->restore();
    16381660    return false;
     
    16471669    paintInfo.context->save();
    16481670    FloatRect unzoomedRect = getUnzoomedRectAndAdjustCurrentContext(o, paintInfo, r);
    1649     wkDrawMediaUIPart(MediaTimeRemainingDisplay, mediaControllerTheme(), paintInfo.context->platformContext(), unzoomedRect, node->active());
     1671    wkDrawMediaUIPart(MediaTimeRemainingDisplay, mediaControllerTheme(), paintInfo.context->platformContext(), unzoomedRect,
     1672         node->active() ? MediaUIPartPressedFlag : 0);
    16501673    paintInfo.context->restore();
    16511674    return false;
  • trunk/WebKitLibraries/ChangeLog

    r45563 r45572  
     12009-07-06  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Update WebKitSystemInterface for <rdar://problem/7008093>.
     4
     5        * WebKitSystemInterface.h:
     6        * libWebKitSystemInterfaceLeopard.a:
     7        * libWebKitSystemInterfaceSnowLeopard.a:
     8        * libWebKitSystemInterfaceTiger.a:
     9
    1102009-07-06  Anders Carlsson  <andersca@apple.com>
    211
  • trunk/WebKitLibraries/WebKitSystemInterface.h

    r45563 r45572  
    221221
    222222typedef enum {
    223     WKMediaControllerStateNormal     = 0,
    224     WKMediaControllerStateActivated  = 1,
    225     WKMediaControllerStateDisabled   = 2
     223    WKMediaControllerFlagDisbled = 1 << 0,
     224    WKMediaControllerFlagPressed = 1 << 1,
     225    WKMediaControllerFlagDrawEndCaps = 1 << 3,
    226226} WKMediaControllerThemeState;
    227227
    228228BOOL WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point);
    229229void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
    230 void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, int state);
    231 void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration);
     230void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
     231void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
    232232
    233233#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && defined(__x86_64__)
Note: See TracChangeset for help on using the changeset viewer.