Changeset 45572 in webkit
- Timestamp:
- Jul 6, 2009 3:56:34 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r45571 r45572 1 2009-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 1 49 2009-07-06 David Kilzer <ddkilzer@apple.com> 2 50 -
trunk/WebCore/platform/mac/WebCoreSystemInterface.h
r45565 r45572 105 105 extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar); 106 106 extern 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); 107 extern void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, 108 float duration, unsigned state); 109 extern void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state); 109 110 extern NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*); 110 111 extern NSArray* (*wkGetExtensionsForMIMEType)(NSString*); -
trunk/WebCore/platform/mac/WebCoreSystemInterface.mm
r45565 r45572 40 40 NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar); 41 41 BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance); 42 void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration); 42 void (*wkDrawMediaSliderTrack)(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, 43 float duration, unsigned state); 43 44 BOOL (*wkHitTestMediaUIPart)(int part, int themeStyle, CGRect bounds, CGPoint point); 44 void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, intstate);45 void (*wkDrawMediaUIPart)(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state); 45 46 void (*wkMeasureMediaUIPart)(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize); 46 47 NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*); -
trunk/WebCore/rendering/MediaControlElements.cpp
r45518 r45572 471 471 // ---------------------------- 472 472 473 MediaControlTimeDisplayElement::MediaControlTimeDisplayElement(Document* doc, PseudoId pseudo, HTMLMediaElement* element) 474 : MediaControlElement(doc, pseudo, element) 475 , m_cachedWidth(Length(0, Fixed)) 476 { 477 } 478 479 void 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 473 495 } //namespace WebCore 474 496 #endif // enable(video) -
trunk/WebCore/rendering/MediaControlElements.h
r45474 r45572 201 201 // ---------------------------- 202 202 203 class MediaControlTimeDisplayElement : public MediaControlElement { 204 public: 205 MediaControlTimeDisplayElement(Document*, PseudoId, HTMLMediaElement*); 206 void setVisible(bool); 207 private: 208 Length m_cachedWidth; 209 }; 210 211 // ---------------------------- 212 203 213 class RenderMediaControlShadowRoot : public RenderBlock { 204 214 public: … … 208 218 209 219 // ---------------------------- 220 210 221 211 222 } //namespace WebCore -
trunk/WebCore/rendering/RenderMedia.cpp
r45474 r45572 68 68 , m_opacityAnimationFrom(0) 69 69 , m_opacityAnimationTo(1.0f) 70 , m_previousVisible(VISIBLE) 70 71 { 71 72 } … … 132 133 IntSize newSize = contentBoxRect().size(); 133 134 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 134 142 controlsRenderer->setLocation(borderLeft() + paddingLeft(), borderTop() + paddingTop()); 135 143 controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed)); … … 222 230 { 223 231 ASSERT(!m_currentTimeDisplay); 224 m_currentTimeDisplay = new MediaControl Element(document(), MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, mediaElement());232 m_currentTimeDisplay = new MediaControlTimeDisplayElement(document(), MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, mediaElement()); 225 233 m_currentTimeDisplay->attachToParent(m_timelineContainer.get()); 226 234 } … … 229 237 { 230 238 ASSERT(!m_timeRemainingDisplay); 231 m_timeRemainingDisplay = new MediaControl Element(document(), MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, mediaElement());239 m_timeRemainingDisplay = new MediaControlTimeDisplayElement(document(), MEDIA_CONTROLS_TIME_REMAINING_DISPLAY, mediaElement()); 232 240 m_timeRemainingDisplay->attachToParent(m_timelineContainer.get()); 233 241 } … … 498 506 } 499 507 508 509 // We want the timeline slider to be at least 100 pixels wide. 510 static const int minWidthToDisplayTimeDisplays = 16 + 16 + 45 + 100 + 45 + 16 + 1; 511 512 bool 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 500 521 } // namespace WebCore 501 522 -
trunk/WebCore/rendering/RenderMedia.h
r45474 r45572 72 72 static String formatTime(float time); 73 73 74 bool shouldShowTimeDisplayControls() const; 75 74 76 void updateFromElement(); 75 77 void updatePlayer(); … … 119 121 RefPtr<MediaControlFullscreenButtonElement> m_fullscreenButton; 120 122 RefPtr<MediaControlTimelineContainerElement> m_timelineContainer; 121 RefPtr<MediaControl Element> m_currentTimeDisplay;122 RefPtr<MediaControl Element> m_timeRemainingDisplay;123 RefPtr<MediaControlTimeDisplayElement> m_currentTimeDisplay; 124 RefPtr<MediaControlTimeDisplayElement> m_timeRemainingDisplay; 123 125 RefPtr<MediaControlStatusDisplayElement> m_statusDisplay; 124 126 RenderObjectChildList m_children; -
trunk/WebCore/rendering/RenderThemeMac.mm
r45569 r45572 35 35 #import "LocalCurrentGraphicsContext.h" 36 36 #import "MediaControlElements.h" 37 #import "RenderMedia.h" 37 38 #import "RenderSlider.h" 38 39 #import "RenderView.h" … … 1478 1479 #if ENABLE(VIDEO) 1479 1480 1481 enum WKMediaControllerThemeState { 1482 MediaUIPartDisbledFlag = 1 << 0, 1483 MediaUIPartPressedFlag = 1 << 1, 1484 MediaUIPartDrawEndCapsFlag = 1 << 3, 1485 }; 1486 1487 1480 1488 // Utility to scale when the UI part are not scaled by wkDrawMediaUIPart 1481 1489 static FloatRect getUnzoomedRectAndAdjustCurrentContext(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect &originalRect) … … 1493 1501 } 1494 1502 1503 1495 1504 bool RenderThemeMac::paintMediaFullscreenButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 1496 1505 { … … 1500 1509 1501 1510 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); 1503 1513 return false; 1504 1514 } … … 1513 1523 if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) { 1514 1524 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 1516 1528 } 1517 1529 return false; … … 1527 1539 if (MediaControlPlayButtonElement* btn = static_cast<MediaControlPlayButtonElement*>(node)) { 1528 1540 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); 1530 1543 } 1531 1544 return false; … … 1539 1552 1540 1553 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; 1543 1557 } 1544 1558 … … 1550 1564 1551 1565 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; 1554 1569 } 1555 1570 … … 1576 1591 paintInfo.context->save(); 1577 1592 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); 1579 1596 paintInfo.context->restore(); 1580 1597 return false; … … 1588 1605 1589 1606 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; 1592 1610 } 1593 1611 … … 1599 1617 1600 1618 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; 1603 1622 } 1604 1623 … … 1610 1629 1611 1630 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; 1614 1634 } 1615 1635 … … 1622 1642 1623 1643 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; 1626 1647 } 1627 1648 … … 1634 1655 paintInfo.context->save(); 1635 1656 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); 1637 1659 paintInfo.context->restore(); 1638 1660 return false; … … 1647 1669 paintInfo.context->save(); 1648 1670 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); 1650 1673 paintInfo.context->restore(); 1651 1674 return false; -
trunk/WebKitLibraries/ChangeLog
r45563 r45572 1 2009-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 1 10 2009-07-06 Anders Carlsson <andersca@apple.com> 2 11 -
trunk/WebKitLibraries/WebKitSystemInterface.h
r45563 r45572 221 221 222 222 typedef enum { 223 WKMediaController StateNormal =0,224 WKMediaController StateActivated =1,225 WKMediaController StateDisabled = 2223 WKMediaControllerFlagDisbled = 1 << 0, 224 WKMediaControllerFlagPressed = 1 << 1, 225 WKMediaControllerFlagDrawEndCaps = 1 << 3, 226 226 } WKMediaControllerThemeState; 227 227 228 228 BOOL WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point); 229 229 void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize); 230 void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, intstate);231 void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration );230 void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state); 231 void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state); 232 232 233 233 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && defined(__x86_64__)
Note: See TracChangeset
for help on using the changeset viewer.