Changeset 55079 in webkit
- Timestamp:
- Feb 22, 2010 5:42:13 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55078 r55079 1 2010-02-22 Nicholas Young <nicholas.young@nokia.com> 2 3 Reviewed by Tor Arne Vestbø. 4 5 [Qt] Switching from Phonon to QtMultimedia Backend for Qt 4.7 6 7 https://bugs.webkit.org/show_bug.cgi?id=34631 8 9 No new tests. This patch only affects multimedia backend. 10 11 * WebCore.pro: Build depends on Qt version. 12 * css/mediaControlsQt.css: Updated media controls. 13 * platform/graphics/MediaPlayer.cpp: Different backend included depending on Qt version. 14 * platform/graphics/qt/MediaPlayerPrivateQt.cpp: Added new QtMultimedia Backend. 15 (WebCore::MediaPlayerPrivate::create): 16 (WebCore::MediaPlayerPrivate::registerMediaEngine): 17 (WebCore::MediaPlayerPrivate::getSupportedTypes): 18 (WebCore::MediaPlayerPrivate::supportsType): 19 (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): 20 (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): 21 (WebCore::MediaPlayerPrivate::hasVideo): 22 (WebCore::MediaPlayerPrivate::hasAudio): 23 (WebCore::MediaPlayerPrivate::load): 24 (WebCore::MediaPlayerPrivate::cancelLoad): 25 (WebCore::MediaPlayerPrivate::play): 26 (WebCore::MediaPlayerPrivate::pause): 27 (WebCore::MediaPlayerPrivate::paused): 28 (WebCore::MediaPlayerPrivate::seek): 29 (WebCore::MediaPlayerPrivate::seeking): 30 (WebCore::MediaPlayerPrivate::duration): 31 (WebCore::MediaPlayerPrivate::currentTime): 32 (WebCore::MediaPlayerPrivate::buffered): 33 (WebCore::MediaPlayerPrivate::maxTimeSeekable): 34 (WebCore::MediaPlayerPrivate::bytesLoaded): 35 (WebCore::MediaPlayerPrivate::totalBytes): 36 (WebCore::MediaPlayerPrivate::setRate): 37 (WebCore::MediaPlayerPrivate::setVolume): 38 (WebCore::MediaPlayerPrivate::supportsMuting): 39 (WebCore::MediaPlayerPrivate::setMuted): 40 (WebCore::MediaPlayerPrivate::networkState): 41 (WebCore::MediaPlayerPrivate::readyState): 42 (WebCore::MediaPlayerPrivate::setVisible): 43 (WebCore::MediaPlayerPrivate::mediaStatusChanged): 44 (WebCore::MediaPlayerPrivate::handleError): 45 (WebCore::MediaPlayerPrivate::stateChanged): 46 (WebCore::MediaPlayerPrivate::nativeSizeChanged): 47 (WebCore::MediaPlayerPrivate::queuedSeekTimeout): 48 (WebCore::MediaPlayerPrivate::seekTimeout): 49 (WebCore::MediaPlayerPrivate::positionChanged): 50 (WebCore::MediaPlayerPrivate::durationChanged): 51 (WebCore::MediaPlayerPrivate::volumeChanged): 52 (WebCore::MediaPlayerPrivate::mutedChanged): 53 (WebCore::MediaPlayerPrivate::updateStates): 54 (WebCore::MediaPlayerPrivate::setSize): 55 (WebCore::MediaPlayerPrivate::naturalSize): 56 (WebCore::MediaPlayerPrivate::paint): 57 (WebCore::MediaPlayerPrivate::repaint): 58 * platform/graphics/qt/MediaPlayerPrivateQt.h: Added new QtMultimedia Backend. 59 (WebCore::MediaPlayerPrivate::isAvailable): 60 (WebCore::MediaPlayerPrivate::supportsFullscreen): 61 * platform/qt/RenderThemeQt.cpp: 62 (WebCore::RenderThemeQt::mediaControlsBaselineOpacity): New method. 63 (WebCore::RenderThemeQt::paintMediaBackground): Background depends on baseline opacity. 64 (WebCore::RenderThemeQt::paintMediaMuteButton): Changed styling. 65 (WebCore::RenderThemeQt::paintMediaCurrentTime): Added current time display. 66 (WebCore::RenderThemeQt::formatMediaControlsCurrentTime): Added time formatting. 67 (WebCore::RenderThemeQt::formatMediaControlsRemainingTime): Added time formatting. 68 (WebCore::RenderThemeQt::paintMediaVolumeSliderTrack): Volume slider added. 69 (WebCore::RenderThemeQt::paintMediaVolumeSliderThumb): Volume slider added. 70 (WebCore::RenderThemeQt::paintMediaSliderTrack): Updated for QtMultimedia. 71 (WebCore::RenderThemeQt::paintMediaSliderThumb): Dropped an unnecessary check. 72 (WebCore::RenderThemeQt::adjustSliderThumbSize): Handle a missing case. 73 * platform/qt/RenderThemeQt.h: Reimplemented a few more methods. 74 1 75 2010-02-22 Alexander Pavlov <apavlov@chromium.org> 2 76 -
trunk/WebCore/WebCore.pro
r55075 r55079 132 132 include($$PWD/../JavaScriptCore/JavaScriptCore.pri) 133 133 134 # Disable HTML5 media compilation if phonon is unavailable 135 !contains(DEFINES, ENABLE_VIDEO=1) { 136 !contains(QT_CONFIG, phonon) { 137 DEFINES -= ENABLE_VIDEO=1 138 DEFINES += ENABLE_VIDEO=0 134 135 # HTML5 Media Support 136 # We require phonon for versions of Qt < 4.7 137 # We require QtMultimedia for versions of Qt >= 4.7 138 !contains(DEFINES, ENABLE_VIDEO=.) { 139 DEFINES -= ENABLE_VIDEO=1 140 DEFINES += ENABLE_VIDEO=0 141 142 lessThan(QT_MINOR_VERSION, 7):contains(QT_CONFIG, phonon) { 143 DEFINES -= ENABLE_VIDEO=0 144 DEFINES += ENABLE_VIDEO=1 145 } 146 !lessThan(QT_MINOR_VERSION, 7):contains(QT_CONFIG, multimedia) { 147 DEFINES -= ENABLE_VIDEO=0 148 DEFINES += ENABLE_VIDEO=1 139 149 } 140 150 } … … 2305 2315 bindings/js/JSAudioConstructor.cpp 2306 2316 2307 HEADERS += \ 2308 platform/graphics/qt/MediaPlayerPrivatePhonon.h 2309 2310 SOURCES += \ 2311 platform/graphics/qt/MediaPlayerPrivatePhonon.cpp 2312 2313 # Add phonon manually to prevent it from coming first in 2314 # the include paths, as Phonon's path.h conflicts with 2315 # WebCore's Path.h on case-insensitive filesystems. 2316 qtAddLibrary(phonon) 2317 INCLUDEPATH -= $$QMAKE_INCDIR_QT/phonon 2318 INCLUDEPATH += $$QMAKE_INCDIR_QT/phonon 2319 mac { 2320 INCLUDEPATH -= $$QMAKE_LIBDIR_QT/phonon.framework/Headers 2321 INCLUDEPATH += $$QMAKE_LIBDIR_QT/phonon.framework/Headers 2317 # QtMultimedia since 4.7 2318 greaterThan(QT_MINOR_VERSION, 6) { 2319 HEADERS += platform/graphics/qt/MediaPlayerPrivateQt.h 2320 SOURCES += platform/graphics/qt/MediaPlayerPrivateQt.cpp 2321 2322 QT += multimedia 2323 } else { 2324 HEADERS += \ 2325 platform/graphics/qt/MediaPlayerPrivatePhonon.h 2326 2327 SOURCES += \ 2328 platform/graphics/qt/MediaPlayerPrivatePhonon.cpp 2329 2330 # Add phonon manually to prevent it from coming first in 2331 # the include paths, as Phonon's path.h conflicts with 2332 # WebCore's Path.h on case-insensitive filesystems. 2333 qtAddLibrary(phonon) 2334 INCLUDEPATH -= $$QMAKE_INCDIR_QT/phonon 2335 INCLUDEPATH += $$QMAKE_INCDIR_QT/phonon 2336 mac { 2337 INCLUDEPATH -= $$QMAKE_LIBDIR_QT/phonon.framework/Headers 2338 INCLUDEPATH += $$QMAKE_LIBDIR_QT/phonon.framework/Headers 2339 } 2322 2340 } 2323 2341 -
trunk/WebCore/css/mediaControlsQt.css
r49175 r55079 52 52 53 53 audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button { 54 left: auto;55 right: 5px;56 54 width: 12px; 57 55 height: 12px; … … 61 59 62 60 audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button { 63 left: 5px;64 61 width: 9px; 65 62 height: 12px; … … 73 70 74 71 audio::-webkit-media-controls-current-time-display, video::-webkit-media-controls-current-time-display { 75 display: none; 72 -webkit-appearance: media-current-time-display; 73 -webkit-user-select: none; 74 display: inline-block; 75 height: 12px; 76 padding: 6px; 77 margin: 5px 3px; 78 79 overflow: hidden; 80 cursor: default; 81 82 text-align: center; 83 font-size: 10px; 84 font-family: Verdana; 85 font-weight: bold; 86 color: white; 76 87 } 77 88 … … 81 92 82 93 audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline { 83 left: 42px;84 right: 34px;85 94 height: 12px; 86 95 padding: 6px 8px; 87 margin: 5px 0px;96 margin: 5px 3px; 88 97 } 89 98 90 99 audio::-webkit-media-controls-volume-slider-container, video::-webkit-media-controls-volume-slider-container { 91 display: none; 100 -webkit-appearance: media-volume-slider-container; 101 position: absolute; 102 height: 103px; 103 width: 24px; 92 104 } 93 105 94 106 audio::-webkit-media-controls-volume-slider, video::-webkit-media-controls-volume-slider { 95 display: none; 107 -webkit-appearance: media-volume-slider; 108 display: inline; 109 position: absolute; 110 111 width: 12px; 112 padding: 6px; 113 height: 88px; 114 margin: 0 0 3px 0; 96 115 } 97 116 98 117 audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button { 99 /* Since MediaControlElements are always created with a renderer we have to hide100 the controls we don't use, so they don't mess up activation and event handling */101 left: 0px;102 top: 0px;103 width: 0px;104 height: 0px;105 106 118 display: none; 107 119 } 108 120 109 121 audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button { 110 /* Since MediaControlElements are always created with a renderer we have to hide111 the controls we don't use, so they don't mess up activation and event handling */112 left: 0px;113 top: 0px;114 width: 0px;115 height: 0px;116 117 122 display: none; 118 123 } 119 124 120 125 audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button { 121 /* Since MediaControlElements are always created with a renderer we have to hide122 the controls we don't use, so they don't mess up activation and event handling */123 left: 0px;124 top: 0px;125 width: 0px;126 height: 0px;127 128 126 display: none; 129 127 } … … 137 135 } 138 136 137 audio::-webkit-media-controls-toggle-closed-captions-button, video::-webkit-media-controls-toggle-closed-captions-button { 138 display: none; 139 } 140 -
trunk/WebCore/platform/graphics/MediaPlayer.cpp
r54826 r55079 38 38 #include "TimeRanges.h" 39 39 40 #if PLATFORM(QT) 41 #include <QtGlobal> 42 #endif 43 40 44 #if PLATFORM(MAC) 41 45 #include "MediaPlayerPrivateQTKit.h" … … 47 51 #include "MediaPlayerPrivateGStreamer.h" 48 52 #elif PLATFORM(QT) 53 #if QT_VERSION < 0x040700 49 54 #include "MediaPlayerPrivatePhonon.h" 55 #else 56 #include "MediaPlayerPrivateQt.h" 57 #endif 50 58 #elif PLATFORM(CHROMIUM) 51 59 #include "MediaPlayerPrivateChromium.h" -
trunk/WebCore/platform/qt/RenderThemeQt.cpp
r54180 r55079 40 40 #include "FontSelector.h" 41 41 #include "GraphicsContext.h" 42 #include "HTMLInputElement.h" 42 43 #include "HTMLMediaElement.h" 43 44 #include "HTMLNames.h" … … 48 49 #include "RenderSlider.h" 49 50 #include "RenderTheme.h" 51 #include "TimeRanges.h" 50 52 #include "ScrollbarThemeQt.h" 51 53 #include "UserAgentStyleSheets.h" … … 883 885 } 884 886 887 double RenderThemeQt::mediaControlsBaselineOpacity() const 888 { 889 return 0.4; 890 } 891 885 892 void RenderThemeQt::paintMediaBackground(QPainter* painter, const IntRect& r) const 886 893 { 887 894 painter->setPen(Qt::NoPen); 888 static QColor transparentBlack(0, 0, 0, 100);895 static QColor transparentBlack(0, 0, 0, mediaControlsBaselineOpacity() * 255); 889 896 painter->setBrush(transparentBlack); 890 897 painter->drawRoundedRect(r.x(), r.y(), r.width(), r.height(), 5.0, 5.0); … … 922 929 QPointF(80, 100), QPointF(50, 70), QPointF(20, 70)}; 923 930 924 p.painter->setBrush( getMediaControlForegroundColor(o));931 p.painter->setBrush(mediaElement->muted() ? Qt::darkRed : getMediaControlForegroundColor(o)); 925 932 p.painter->drawPolygon(speakerPolygon, 6); 926 927 if (mediaElement->muted()) {928 p.painter->setPen(Qt::red);929 p.painter->drawLine(0, 100, 100, 0);930 }931 933 932 934 return false; … … 972 974 } 973 975 976 bool RenderThemeQt::paintMediaCurrentTime(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 977 { 978 StylePainter p(this, paintInfo); 979 if (!p.isValid()) 980 return true; 981 982 p.painter->setRenderHint(QPainter::Antialiasing, true); 983 paintMediaBackground(p.painter, r); 984 985 return false; 986 } 987 988 String RenderThemeQt::formatMediaControlsCurrentTime(float currentTime, float duration) const 989 { 990 return formatMediaControlsTime(currentTime) + " / " + formatMediaControlsTime(duration); 991 } 992 993 String RenderThemeQt::formatMediaControlsRemainingTime(float currentTime, float duration) const 994 { 995 return String(); 996 } 997 998 bool RenderThemeQt::paintMediaVolumeSliderTrack(RenderObject *o, const RenderObject::PaintInfo &paintInfo, const IntRect &r) 999 { 1000 StylePainter p(this, paintInfo); 1001 if (!p.isValid()) 1002 return true; 1003 1004 p.painter->setRenderHint(QPainter::Antialiasing, true); 1005 1006 paintMediaBackground(p.painter, r); 1007 1008 if (!o->isSlider()) 1009 return false; 1010 1011 IntRect b = toRenderBox(o)->contentBoxRect(); 1012 1013 // Position the outer rectangle 1014 int top = r.y() + b.y(); 1015 int left = r.x() + b.x(); 1016 int width = b.width(); 1017 int height = b.height(); 1018 1019 // Get the scale color from the page client 1020 QPalette pal = QApplication::palette(); 1021 setPaletteFromPageClientIfExists(pal); 1022 const QColor highlightText = pal.brush(QPalette::Active, QPalette::HighlightedText).color(); 1023 const QColor scaleColor(highlightText.red(), highlightText.green(), highlightText.blue(), mediaControlsBaselineOpacity() * 255); 1024 1025 // Draw the outer rectangle 1026 p.painter->setBrush(scaleColor); 1027 p.painter->drawRect(left, top, width, height); 1028 1029 if (!o->node() || !o->node()->hasTagName(inputTag)) 1030 return false; 1031 1032 HTMLInputElement* slider = static_cast<HTMLInputElement*>(o->node()); 1033 1034 // Position the inner rectangle 1035 height = height * slider->valueAsNumber(); 1036 top += b.height() - height; 1037 1038 // Draw the inner rectangle 1039 p.painter->setPen(Qt::NoPen); 1040 p.painter->setBrush(getMediaControlForegroundColor(o)); 1041 p.painter->drawRect(left, top, width, height); 1042 1043 return false; 1044 } 1045 1046 bool RenderThemeQt::paintMediaVolumeSliderThumb(RenderObject *o, const RenderObject::PaintInfo &paintInfo, const IntRect &r) 1047 { 1048 StylePainter p(this, paintInfo); 1049 if (!p.isValid()) 1050 return true; 1051 1052 // Nothing to draw here, this is all done in the track 1053 return false; 1054 } 1055 974 1056 bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 975 1057 { … … 986 1068 paintMediaBackground(p.painter, r); 987 1069 1070 #if QT_VERSION >= 0x040700 1071 if (MediaPlayer* player = mediaElement->player()) { 1072 // Get the buffered parts of the media 1073 PassRefPtr<TimeRanges> buffered = player->buffered(); 1074 if (buffered->length() > 0 && player->duration() < std::numeric_limits<float>::infinity()) { 1075 // Set the transform and brush 1076 WorldMatrixTransformer transformer(p.painter, o, r); 1077 p.painter->setBrush(getMediaControlForegroundColor()); 1078 1079 // Paint each buffered section 1080 ExceptionCode ex; 1081 for (int i = 0; i < buffered->length(); i++) { 1082 float startX = (buffered->start(i, ex) / player->duration()) * 100; 1083 float width = ((buffered->end(i, ex) / player->duration()) * 100) - startX; 1084 p.painter->drawRect(startX, 37, width, 26); 1085 } 1086 } 1087 } 1088 #endif 1089 988 1090 return false; 989 1091 } … … 991 1093 bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) 992 1094 { 993 HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o->parent());994 if (!mediaElement)995 return false;996 997 1095 StylePainter p(this, paintInfo); 998 1096 if (!p.isValid()) … … 1020 1118 o->style()->setWidth(Length(parentHeight / 3, Fixed)); 1021 1119 o->style()->setHeight(Length(parentHeight, Fixed)); 1120 } else if (part == MediaVolumeSliderThumbPart) { 1121 RenderStyle* parentStyle = o->parent()->style(); 1122 Q_ASSERT(parentStyle); 1123 1124 int parentWidth = parentStyle->width().value(); 1125 o->style()->setHeight(Length(parentWidth / 3, Fixed)); 1126 o->style()->setWidth(Length(parentWidth, Fixed)); 1022 1127 } else if (part == SliderThumbHorizontalPart || part == SliderThumbVerticalPart) { 1023 1128 QStyleOptionSlider option; -
trunk/WebCore/platform/qt/RenderThemeQt.h
r54180 r55079 128 128 virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 129 129 virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 130 130 virtual bool paintMediaCurrentTime(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 131 virtual bool paintMediaVolumeSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 132 virtual bool paintMediaVolumeSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 133 virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const; 134 virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const; 131 135 private: 132 136 HTMLMediaElement* getMediaElementFromRenderObject(RenderObject* o) const; 133 137 void paintMediaBackground(QPainter* painter, const IntRect& r) const; 138 double mediaControlsBaselineOpacity() const; 134 139 QColor getMediaControlForegroundColor(RenderObject* o = 0) const; 135 140 #endif
Note: See TracChangeset
for help on using the changeset viewer.