2011-01-17 Yi Shen <yi.4.shen@nokia.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Jan 2011 16:00:31 +0000 (16:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Jan 2011 16:00:31 +0000 (16:00 +0000)
        Reviewed by Andreas Kling.

        [Qt] Extend the Platform Plugin to support full screen video handler
        https://bugs.webkit.org/show_bug.cgi?id=51249

        Make MediaPlayerPrivateQt support a fullscreen player.

        No new tests because LayoutTests/media/media-fullscreen-inline.html already exists.
        However, this test failed for Qt (QtMediaPlayer) due to durationchange event getting fired twice.
        So, still skip it for Qt.

        * WebCore.pro:
        * features.pri:
        * platform/graphics/qt/MediaPlayerPrivateQt.cpp:
        (WebCore::MediaPlayerPrivateQt::MediaPlayerPrivateQt):
        (WebCore::MediaPlayerPrivateQt::removeVideoItem):
        (WebCore::MediaPlayerPrivateQt::restoreVideoItem):
        * platform/graphics/qt/MediaPlayerPrivateQt.h:
        (WebCore::MediaPlayerPrivateQt::supportsFullscreen):
        (WebCore::MediaPlayerPrivateQt::mediaPlayer):
2011-01-17  Yi Shen  <yi.4.shen@nokia.com>

        Reviewed by Andreas Kling.

        [Qt] Extend the Platform Plugin to support full screen video handler
        https://bugs.webkit.org/show_bug.cgi?id=51249

        Add a new webkit platform plugin interface to support full screen video handler.

        * Api/qwebkitplatformplugin.h:
        (QWebFullScreenVideoHandler::QWebFullScreenVideoHandler):
        (QWebFullScreenVideoHandler::~QWebFullScreenVideoHandler):
        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::ChromeClientQt):
        (WebCore::ChromeClientQt::~ChromeClientQt):
        (WebCore::ChromeClientQt::fullScreenVideo):
        (WebCore::ChromeClientQt::supportsFullscreenForNode):
        (WebCore::ChromeClientQt::requiresFullscreenForVideoPlayback):
        (WebCore::ChromeClientQt::enterFullscreenForNode):
        (WebCore::ChromeClientQt::exitFullscreenForNode):
        * WebCoreSupport/ChromeClientQt.h:
        * WebCoreSupport/FullScreenVideoQt.cpp: Added.
        (WebCore::FullScreenVideoQt::FullScreenVideoQt):
        (WebCore::FullScreenVideoQt::~FullScreenVideoQt):
        (WebCore::FullScreenVideoQt::enterFullScreenForNode):
        (WebCore::FullScreenVideoQt::exitFullScreenForNode):
        (WebCore::FullScreenVideoQt::aboutToClose):
        (WebCore::FullScreenVideoQt::mediaPlayer):
        (WebCore::FullScreenVideoQt::mediaPlayerForNode):
        (WebCore::FullScreenVideoQt::requiresFullScreenForVideoPlayback):
        * WebCoreSupport/FullScreenVideoQt.h: Added.
        (WebCore::FullScreenVideoQt::isValid):
        * WebCoreSupport/QtPlatformPlugin.cpp:
        (WebCore::QtPlatformPlugin::createFullScreenVideoHandler):
        * WebCoreSupport/QtPlatformPlugin.h:
        * examples/platformplugin/WebPlugin.cpp:
        (FullScreenVideoWidget::FullScreenVideoWidget):
        (FullScreenVideoWidget::event):
        (FullScreenVideoWidget::keyPressEvent):
        (FullScreenVideoHandler::FullScreenVideoHandler):
        (FullScreenVideoHandler::~FullScreenVideoHandler):
        (FullScreenVideoHandler::requiresFullScreenForVideoPlayback):
        (FullScreenVideoHandler::enterFullScreen):
        (FullScreenVideoHandler::exitFullScreen):
        (WebPlugin::supportsExtension):
        (WebPlugin::createExtension):
        * examples/platformplugin/WebPlugin.h:
        (FullScreenVideoWidget::~FullScreenVideoWidget):
        * examples/platformplugin/platformplugin.pro:
        * examples/platformplugin/qwebkitplatformplugin.h:
        (QWebFullScreenVideoHandler::QWebFullScreenVideoHandler):
        (QWebFullScreenVideoHandler::~QWebFullScreenVideoHandler):

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.pro
Source/WebCore/features.pri
Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
Source/WebKit/qt/Api/qwebkitplatformplugin.h
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp [new file with mode: 0644]
Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h [new file with mode: 0644]
Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
Source/WebKit/qt/examples/platformplugin/WebPlugin.cpp
Source/WebKit/qt/examples/platformplugin/WebPlugin.h
Source/WebKit/qt/examples/platformplugin/platformplugin.pro
Source/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h

index 89ee8c0e13db3dfbc845c0e9e51afc668129d7db..bffb3d70d315840c52ae35620f3afccbc373b229 100644 (file)
@@ -1,3 +1,26 @@
+2011-01-17  Yi Shen  <yi.4.shen@nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        [Qt] Extend the Platform Plugin to support full screen video handler
+        https://bugs.webkit.org/show_bug.cgi?id=51249
+
+        Make MediaPlayerPrivateQt support a fullscreen player.
+
+        No new tests because LayoutTests/media/media-fullscreen-inline.html already exists.
+        However, this test failed for Qt (QtMediaPlayer) due to durationchange event getting fired twice.
+        So, still skip it for Qt.
+
+        * WebCore.pro:
+        * features.pri:
+        * platform/graphics/qt/MediaPlayerPrivateQt.cpp:
+        (WebCore::MediaPlayerPrivateQt::MediaPlayerPrivateQt):
+        (WebCore::MediaPlayerPrivateQt::removeVideoItem):
+        (WebCore::MediaPlayerPrivateQt::restoreVideoItem):
+        * platform/graphics/qt/MediaPlayerPrivateQt.h:
+        (WebCore::MediaPlayerPrivateQt::supportsFullscreen):
+        (WebCore::MediaPlayerPrivateQt::mediaPlayer):
+
 2011-01-17  Anthony Ricaud  <rik@webkit.org>
 
         Reviewed by Kent Tamura.
index 7af008c5ad44aa1e1676e83fec8ca2f0774c2d8a..b37bf4530506b2b25aa26035249637292aa731d0 100644 (file)
@@ -3257,8 +3257,13 @@ contains(DEFINES, ENABLE_VIDEO=1) {
 
         PKGCONFIG += glib-2.0 gio-2.0 gstreamer-0.10 gstreamer-app-0.10 gstreamer-base-0.10 gstreamer-interfaces-0.10 gstreamer-pbutils-0.10 gstreamer-plugins-base-0.10 gstreamer-video-0.10
      } else:contains(MOBILITY_CONFIG, multimedia) {
-        HEADERS += platform/graphics/qt/MediaPlayerPrivateQt.h
-        SOURCES += platform/graphics/qt/MediaPlayerPrivateQt.cpp
+        HEADERS += \ 
+            platform/graphics/qt/MediaPlayerPrivateQt.h \
+            $$PWD/../../WebKit/qt/WebCoreSupport/FullScreenVideoQt.h
+
+        SOURCES += \
+            platform/graphics/qt/MediaPlayerPrivateQt.cpp \
+            $$PWD/../../WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp
 
         CONFIG *= mobility
         MOBILITY += multimedia
index ff54b14a9e0c6234727dbf6a901c599a1192cdb3..fdf11ed850a01e0c4d4585a5ac282abecc170256 100644 (file)
@@ -152,9 +152,13 @@ contains(MOBILITY_CONFIG, sensors) {
     contains(MOBILITY_CONFIG, multimedia) {
         DEFINES -= ENABLE_VIDEO=0
         DEFINES += ENABLE_VIDEO=1
+        DEFINES -= ENABLE_QT_MULTIMEDIA=0
+        DEFINES += ENABLE_QT_MULTIMEDIA=1
     } else:contains(QT_CONFIG, phonon) {
         DEFINES -= ENABLE_VIDEO=0
         DEFINES += ENABLE_VIDEO=1
+        DEFINES -= ENABLE_QT_MULTIMEDIA=1
+        DEFINES += ENABLE_QT_MULTIMEDIA=0
     }
 }
 
index dd4b6e614e38b5aa3d52669aea9d548d4c69b13a..be6f732f4da9386f4fdaf6bbf9ca6b42d7a29666 100644 (file)
@@ -108,7 +108,7 @@ MediaPlayerPrivateQt::MediaPlayerPrivateQt(MediaPlayer* player)
     , m_queuedSeek(-1)
     , m_preload(MediaPlayer::Auto)
 {
-    m_mediaPlayer->bind(m_videoItem);
+    m_mediaPlayer->setVideoOutput(m_videoItem);
     m_videoScene->addItem(m_videoItem);
 
     // Signal Handlers
@@ -587,6 +587,22 @@ IntSize MediaPlayerPrivateQt::naturalSize() const
     return m_naturalSize;
 }
 
+void MediaPlayerPrivateQt::removeVideoItem()
+{
+    m_oldNaturalSize = m_naturalSize;
+    m_mediaPlayer->setVideoOutput(static_cast<QGraphicsVideoItem*>(0));
+    m_videoScene->removeItem(m_videoItem);
+}
+
+void MediaPlayerPrivateQt::restoreVideoItem()
+{
+    m_mediaPlayer->setVideoOutput(m_videoItem);
+    m_videoScene->addItem(m_videoItem);
+    // FIXME: a qtmobility bug, need to reset the size when restore the videoitem, otherwise the size is 0
+    // http://bugreports.qt.nokia.com/browse/QTMOBILITY-971
+    nativeSizeChanged(QSize(m_oldNaturalSize));
+}
+
 void MediaPlayerPrivateQt::paint(GraphicsContext* context, const IntRect& rect)
 {
 #if USE(ACCELERATED_COMPOSITING)
index 93c9d1cb65206c3767b0e4dfd2fce6a24a5d5bf5..2621432c5fb8ff06187229bf32c0bc87f720a794 100644 (file)
@@ -90,7 +90,7 @@ public:
 
     void paint(GraphicsContext*, const IntRect&);
 
-    bool supportsFullscreen() const { return false; }
+    bool supportsFullscreen() const { return true; }
 
 #if USE(ACCELERATED_COMPOSITING)
 #if USE(TEXTURE_MAPPER)
@@ -108,6 +108,11 @@ public:
 #endif
 
     virtual PlatformMedia platformMedia() const;
+
+    QMediaPlayer* mediaPlayer() const { return m_mediaPlayer; }
+    void removeVideoItem();
+    void restoreVideoItem();
+
 private slots:
     void mediaStatusChanged(QMediaPlayer::MediaStatus);
     void handleError(QMediaPlayer::Error);
@@ -142,6 +147,7 @@ private:
 
     IntSize m_currentSize;
     IntSize m_naturalSize;
+    IntSize m_oldNaturalSize;
     bool m_isVisible;
     bool m_isSeeking;
     bool m_composited;
index b8cc984a34458700be20b92f45686ee857240320..2a94e0cd8cfac87585473d0bcf946c101bca3f40 100644 (file)
@@ -28,6 +28,9 @@
 
 #include <QObject>
 #include <QUrl>
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+#include <QMediaPlayer>
+#endif
 
 class QWebSelectData
 {
@@ -115,6 +118,23 @@ public:
     virtual unsigned hitTestPaddingForTouch(const PaddingDirection) const = 0;
 };
 
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+class QWebFullScreenVideoHandler : public QObject {
+    Q_OBJECT
+public:
+    QWebFullScreenVideoHandler() {}
+    virtual ~QWebFullScreenVideoHandler() {}
+    virtual bool requiresFullScreenForVideoPlayback() const = 0;
+
+Q_SIGNALS:
+    void fullScreenClosed();
+
+public Q_SLOTS:
+    virtual void enterFullScreen(QMediaPlayer*) = 0;
+    virtual void exitFullScreen() = 0;
+};
+#endif
+
 class QWebKitPlatformPlugin
 {
 public:
@@ -124,7 +144,8 @@ public:
         MultipleSelections,
         Notifications,
         Haptics,
-        TouchInteraction
+        TouchInteraction,
+        FullScreenVideoPlayer
     };
 
     virtual bool supportsExtension(Extension extension) const = 0;
@@ -132,7 +153,7 @@ public:
 };
 
 QT_BEGIN_NAMESPACE
-Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.6");
+Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.7");
 QT_END_NAMESPACE
 
 #endif // QWEBKITPLATFORMPLUGIN_H
index 26394ec73ff8d08902e57ece6fd0744e81da8dc0..7ccb0d40e22ca5e199722dd9816f1ac2269d788f 100644 (file)
@@ -1,3 +1,56 @@
+2011-01-17  Yi Shen  <yi.4.shen@nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        [Qt] Extend the Platform Plugin to support full screen video handler
+        https://bugs.webkit.org/show_bug.cgi?id=51249
+
+        Add a new webkit platform plugin interface to support full screen video handler.
+
+        * Api/qwebkitplatformplugin.h:
+        (QWebFullScreenVideoHandler::QWebFullScreenVideoHandler):
+        (QWebFullScreenVideoHandler::~QWebFullScreenVideoHandler):
+        * WebCoreSupport/ChromeClientQt.cpp:
+        (WebCore::ChromeClientQt::ChromeClientQt):
+        (WebCore::ChromeClientQt::~ChromeClientQt):
+        (WebCore::ChromeClientQt::fullScreenVideo):
+        (WebCore::ChromeClientQt::supportsFullscreenForNode):
+        (WebCore::ChromeClientQt::requiresFullscreenForVideoPlayback):
+        (WebCore::ChromeClientQt::enterFullscreenForNode):
+        (WebCore::ChromeClientQt::exitFullscreenForNode):
+        * WebCoreSupport/ChromeClientQt.h:
+        * WebCoreSupport/FullScreenVideoQt.cpp: Added.
+        (WebCore::FullScreenVideoQt::FullScreenVideoQt):
+        (WebCore::FullScreenVideoQt::~FullScreenVideoQt):
+        (WebCore::FullScreenVideoQt::enterFullScreenForNode):
+        (WebCore::FullScreenVideoQt::exitFullScreenForNode):
+        (WebCore::FullScreenVideoQt::aboutToClose):
+        (WebCore::FullScreenVideoQt::mediaPlayer):
+        (WebCore::FullScreenVideoQt::mediaPlayerForNode):
+        (WebCore::FullScreenVideoQt::requiresFullScreenForVideoPlayback):
+        * WebCoreSupport/FullScreenVideoQt.h: Added.
+        (WebCore::FullScreenVideoQt::isValid):
+        * WebCoreSupport/QtPlatformPlugin.cpp:
+        (WebCore::QtPlatformPlugin::createFullScreenVideoHandler):
+        * WebCoreSupport/QtPlatformPlugin.h:
+        * examples/platformplugin/WebPlugin.cpp:
+        (FullScreenVideoWidget::FullScreenVideoWidget):
+        (FullScreenVideoWidget::event):
+        (FullScreenVideoWidget::keyPressEvent):
+        (FullScreenVideoHandler::FullScreenVideoHandler):
+        (FullScreenVideoHandler::~FullScreenVideoHandler):
+        (FullScreenVideoHandler::requiresFullScreenForVideoPlayback):
+        (FullScreenVideoHandler::enterFullScreen):
+        (FullScreenVideoHandler::exitFullScreen):
+        (WebPlugin::supportsExtension):
+        (WebPlugin::createExtension):
+        * examples/platformplugin/WebPlugin.h:
+        (FullScreenVideoWidget::~FullScreenVideoWidget):
+        * examples/platformplugin/platformplugin.pro:
+        * examples/platformplugin/qwebkitplatformplugin.h:
+        (QWebFullScreenVideoHandler::QWebFullScreenVideoHandler):
+        (QWebFullScreenVideoHandler::~QWebFullScreenVideoHandler):
+
 2011-01-16  Adam Barth  <abarth@webkit.org>
 
         Rubber-stamped by Eric Seidel.
index 6116ae77860e0d45fa25f42b03541a70bde0084d..acb136a38ae181cfcc96c061eb4c24216f39b963 100644 (file)
 #include <qtooltip.h>
 #include <wtf/OwnPtr.h>
 
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+#include "FullScreenVideoQt.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "HTMLVideoElement.h"
+#include "MediaPlayerPrivateQt.h"
+#endif
+
 namespace WebCore {
 
 bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
@@ -83,6 +91,9 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
 ChromeClientQt::ChromeClientQt(QWebPage* webPage)
     : m_webPage(webPage)
     , m_eventLoop(0)
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+    , m_fullScreenVideo(0)
+#endif
 {
     toolBarsVisible = statusBarVisible = menuBarVisible = true;
 }
@@ -91,6 +102,10 @@ ChromeClientQt::~ChromeClientQt()
 {
     if (m_eventLoop)
         m_eventLoop->exit();
+
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+    delete m_fullScreenVideo;
+#endif
 }
 
 void ChromeClientQt::setWindowRect(const FloatRect& rect)
@@ -648,6 +663,54 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
 }
 #endif
 
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+FullScreenVideoQt* ChromeClientQt::fullScreenVideo()
+{
+    if (!m_fullScreenVideo)
+        m_fullScreenVideo = new FullScreenVideoQt(this);
+    return m_fullScreenVideo;
+}
+
+bool ChromeClientQt::supportsFullscreenForNode(const Node* node)
+{
+    ASSERT(node);
+    return node->hasTagName(HTMLNames::videoTag) && fullScreenVideo()->isValid();
+}
+
+bool ChromeClientQt::requiresFullscreenForVideoPlayback()
+{
+    return fullScreenVideo()->requiresFullScreenForVideoPlayback();
+}
+
+void ChromeClientQt::enterFullscreenForNode(Node* node)
+{
+    ASSERT(node && node->hasTagName(HTMLNames::videoTag));
+
+    HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
+    PlatformMedia platformMedia = videoElement->platformMedia();
+
+    ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
+    if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
+        return;
+
+    fullScreenVideo()->enterFullScreenForNode(node);
+}
+
+void ChromeClientQt::exitFullscreenForNode(Node* node)
+{
+    ASSERT(node && node->hasTagName(HTMLNames::videoTag));
+
+    HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(node);
+    PlatformMedia platformMedia = videoElement->platformMedia();
+
+    ASSERT(platformMedia.type == PlatformMedia::QtMediaPlayerType);
+    if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
+        return;
+
+    fullScreenVideo()->exitFullScreenForNode(node);
+} 
+#endif
+
 QWebSelectMethod* ChromeClientQt::createSelectPopup() const
 {
     QWebSelectMethod* result = m_platformPlugin.createSelectInputMethod();
index bcf8975686ae950bc2f11d1d5ba628a0b6d9cfd6..d8c2f57a69f8fea17d6b23e1941e5fd2a68c5807 100644 (file)
@@ -50,6 +50,9 @@ namespace WebCore {
     struct FrameLoadRequest;
     class QtAbstractWebPopup;
     struct ViewportArguments;
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+    class FullScreenVideoQt;
+#endif
 
     class ChromeClientQt : public ChromeClient
     {
@@ -162,6 +165,14 @@ namespace WebCore {
 #if ENABLE(TOUCH_EVENTS)
         virtual void needTouchEvents(bool) { }
 #endif
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+        virtual bool supportsFullscreenForNode(const Node*);
+        virtual void enterFullscreenForNode(Node*);
+        virtual void exitFullscreenForNode(Node*);
+        virtual bool requiresFullscreenForVideoPlayback();
+        FullScreenVideoQt* fullScreenVideo();
+#endif
 
         virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
         virtual void chooseIconForFiles(const Vector<String>&, FileChooser*);
@@ -196,6 +207,10 @@ namespace WebCore {
         bool menuBarVisible;
         QEventLoop* m_eventLoop;
 
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+        FullScreenVideoQt* m_fullScreenVideo;
+#endif
+
         static bool dumpVisitedLinksCallbacks;
 
         mutable QtPlatformPlugin m_platformPlugin;
diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp
new file mode 100644 (file)
index 0000000..bdc22e5
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "FullScreenVideoQt.h"
+
+#include "ChromeClientQt.h"
+#include "HTMLNames.h"
+#include "HTMLVideoElement.h"
+#include "MediaPlayerPrivateQt.h"
+#include "Node.h"
+#include "qwebkitplatformplugin.h"
+
+#include <QGraphicsVideoItem>
+
+namespace WebCore {
+
+FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient)
+    : m_chromeClient(chromeClient)
+    , m_videoElement(0)
+{
+    Q_ASSERT(m_chromeClient);
+    m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler();
+
+    if (m_FullScreenVideoHandler)
+        connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose()));
+}
+
+FullScreenVideoQt::~FullScreenVideoQt()
+{
+    delete m_FullScreenVideoHandler;
+}
+
+void FullScreenVideoQt::enterFullScreenForNode(Node* node)
+{
+    Q_ASSERT(node);
+    Q_ASSERT(m_FullScreenVideoHandler);
+
+    if (!m_FullScreenVideoHandler)
+        return;
+
+    MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayerForNode(node);
+    mediaPlayerQt->removeVideoItem();
+    m_FullScreenVideoHandler->enterFullScreen(mediaPlayerQt->mediaPlayer());
+}
+
+void FullScreenVideoQt::exitFullScreenForNode(Node* node)
+{
+    Q_ASSERT(node);
+    Q_ASSERT(m_FullScreenVideoHandler);
+
+    if (!m_FullScreenVideoHandler)
+        return;
+
+    m_FullScreenVideoHandler->exitFullScreen();
+    MediaPlayerPrivateQt* mediaPlayerQt = mediaPlayerForNode(node);
+    mediaPlayerQt->restoreVideoItem();
+}
+
+void FullScreenVideoQt::aboutToClose()
+{
+    Q_ASSERT(m_videoElement);
+    m_videoElement->exitFullscreen();
+}
+
+MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayer()
+{
+    Q_ASSERT(m_videoElement);
+    PlatformMedia platformMedia = m_videoElement->platformMedia();
+    return static_cast<MediaPlayerPrivateQt*>(platformMedia.media.qtMediaPlayer);
+}
+
+MediaPlayerPrivateQt* FullScreenVideoQt::mediaPlayerForNode(Node* node)
+{
+    Q_ASSERT(node);
+    if (node)
+        m_videoElement = static_cast<HTMLVideoElement*>(node);
+    return mediaPlayer();
+}
+
+bool FullScreenVideoQt::requiresFullScreenForVideoPlayback()
+{
+    return m_FullScreenVideoHandler ? m_FullScreenVideoHandler->requiresFullScreenForVideoPlayback() : false;
+}
+
+}
+
diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h
new file mode 100644 (file)
index 0000000..637da70
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef FullScreenVideoQt_h
+#define FullScreenVideoQt_h
+
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+class QGraphicsVideoItem;
+QT_END_NAMESPACE
+
+class QWebFullScreenVideoHandler;
+
+namespace WebCore {
+
+class ChromeClientQt;
+class HTMLVideoElement;
+class Node;
+class MediaPlayerPrivateQt;
+
+class FullScreenVideoQt : public QObject {
+    Q_OBJECT
+public:
+    FullScreenVideoQt(ChromeClientQt*);
+    ~FullScreenVideoQt();
+
+    virtual void enterFullScreenForNode(Node*);
+    virtual void exitFullScreenForNode(Node*);
+    bool requiresFullScreenForVideoPlayback();
+    bool isValid() const {  return m_FullScreenVideoHandler; }
+
+private:
+    MediaPlayerPrivateQt* mediaPlayer();
+    MediaPlayerPrivateQt* mediaPlayerForNode(Node* = 0);
+
+private slots:
+    void aboutToClose();
+
+private:
+    ChromeClientQt* m_chromeClient;
+    HTMLVideoElement* m_videoElement;
+    QWebFullScreenVideoHandler* m_FullScreenVideoHandler;
+};
+
+}
+
+#endif // PopupMenuQt_h
index e4b89b43a915ca32e10c6761db4da3b201fd184d..ea561341c50204ea9d144f17ae1fe6a39b3fa447 100644 (file)
@@ -127,4 +127,12 @@ QWebTouchModifier* QtPlatformPlugin::createTouchModifier()
     return p ? static_cast<QWebTouchModifier*>(p->createExtension(QWebKitPlatformPlugin::TouchInteraction)) : 0;
 }
 
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+QWebFullScreenVideoHandler* QtPlatformPlugin::createFullScreenVideoHandler()
+{
+    QWebKitPlatformPlugin* p = plugin();
+    return p ? static_cast<QWebFullScreenVideoHandler*>(p->createExtension(QWebKitPlatformPlugin::FullScreenVideoPlayer)) : 0;
+}
+#endif
+
 }
index 365b734d05d6d8d6d6b926a3dca4fcb47dea16be..71ee2bb698d985b8be82d7366595f53d27e2300d 100644 (file)
@@ -29,6 +29,9 @@ class QWebNotificationPresenter;
 class QWebHapticFeedbackPlayer;
 class QWebSelectData;
 class QWebTouchModifier;
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+class QWebFullScreenVideoHandler;
+#endif
 
 namespace WebCore {
 
@@ -41,6 +44,9 @@ public:
     QWebNotificationPresenter* createNotificationPresenter();
     QWebHapticFeedbackPlayer* createHapticFeedbackPlayer();
     QWebTouchModifier* createTouchModifier();
+#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+    QWebFullScreenVideoHandler* createFullScreenVideoHandler();
+#endif
 
     QWebKitPlatformPlugin* plugin();
 
index d029b738e50c9ebeb208edb321efaa9f532b8c1e..320079ffb3d04160d8e007c9bac235a53fcd0c43 100644 (file)
@@ -19,7 +19,9 @@
  */
 #include "WebPlugin.h"
 
+#include <QEvent>
 #include <QHBoxLayout>
+#include <QKeyEvent>
 #include <QListWidget>
 #include <QListWidgetItem>
 #include <QPainter>
@@ -208,6 +210,71 @@ MultipleSelectionPopup::MultipleSelectionPopup(const QWebSelectData& data)
     resize(size().width(), visibleItemCount * gMaemoListItemSize);
 }
 
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+FullScreenVideoWidget::FullScreenVideoWidget(QMediaPlayer* player)
+    : QVideoWidget()
+    , m_mediaPlayer(player)
+{
+    Q_ASSERT(m_mediaPlayer);
+
+    setFullScreen(true);
+    m_mediaPlayer->setVideoOutput(this);
+}
+
+bool FullScreenVideoWidget::event(QEvent* ev)
+{
+    if (ev->type() ==  QEvent::MouseButtonDblClick) {
+        emit fullScreenClosed();
+        ev->accept();
+        return true;
+    } 
+    return QWidget::event(ev);
+}
+
+void FullScreenVideoWidget::keyPressEvent(QKeyEvent* ev)
+{
+    if (ev->key() == Qt::Key_Space) {
+        if (m_mediaPlayer->state() == QMediaPlayer::PlayingState)
+            m_mediaPlayer->pause();
+        else
+            m_mediaPlayer->play();
+        ev->accept();
+        return;
+    }
+}
+
+FullScreenVideoHandler::FullScreenVideoHandler()
+    : m_mediaWidget(0)
+{
+}
+
+FullScreenVideoHandler::~FullScreenVideoHandler()
+{
+    delete m_mediaWidget;
+}
+
+bool FullScreenVideoHandler::requiresFullScreenForVideoPlayback() const
+{
+    return true;
+}
+
+void FullScreenVideoHandler::enterFullScreen(QMediaPlayer* player)
+{
+    Q_ASSERT(player);
+
+    m_mediaWidget = new FullScreenVideoWidget(player);
+    connect(m_mediaWidget, SIGNAL(fullScreenClosed()), this, SIGNAL(fullScreenClosed()));
+    m_mediaWidget->showFullScreen();
+}
+
+void FullScreenVideoHandler::exitFullScreen()
+{
+    m_mediaWidget->hide();
+    delete m_mediaWidget;
+    m_mediaWidget = 0;
+}
+#endif
+
 bool WebPlugin::supportsExtension(Extension extension) const
 {
     switch (extension) {
@@ -219,6 +286,10 @@ bool WebPlugin::supportsExtension(Extension extension) const
 #endif
     case TouchInteraction:
         return true;
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+    case FullScreenVideoPlayer:
+        return true;
+#endif
     default:
         return false;
     }
@@ -235,6 +306,10 @@ QObject* WebPlugin::createExtension(Extension extension) const
 #endif
     case TouchInteraction:
         return new TouchModifier();
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+    case FullScreenVideoPlayer:
+        return new FullScreenVideoHandler();
+#endif
     default:
         return 0;
     }
index 0243f57d79aeaccaf9357eb62db4bc6949883fc3..4994669bea1813cc91531926d921473c1ab002fd 100644 (file)
@@ -24,6 +24,9 @@
 #include "WebNotificationPresenter.h"
 
 #include <QDialog>
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+#include <QVideoWidget>
+#endif
 
 class QListWidgetItem;
 class QListWidget;
@@ -94,6 +97,40 @@ public:
     }
 };
 
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+class FullScreenVideoWidget : public QVideoWidget {
+    Q_OBJECT
+public:
+    FullScreenVideoWidget(QMediaPlayer*);
+    virtual ~FullScreenVideoWidget() {}
+
+Q_SIGNALS:
+    void fullScreenClosed();
+
+protected:
+    bool event(QEvent*);
+    void keyPressEvent(QKeyEvent*);
+
+private:
+    QMediaPlayer* m_mediaPlayer; // not owned
+};
+
+class FullScreenVideoHandler : public QWebFullScreenVideoHandler {
+    Q_OBJECT
+public:
+    FullScreenVideoHandler();
+    virtual ~FullScreenVideoHandler();
+    bool requiresFullScreenForVideoPlayback() const;
+
+public Q_SLOTS:
+    void enterFullScreen(QMediaPlayer*);
+    void exitFullScreen();
+
+private:
+    FullScreenVideoWidget* m_mediaWidget; // owned
+};
+#endif
+
 class WebPlugin : public QObject, public QWebKitPlatformPlugin
 {
     Q_OBJECT
index 9275665727866b2e0c5dc667776a08bfdcb511fc..ccc0b3a2bfee64afba08c21704c9d66e27cc0577 100644 (file)
@@ -3,6 +3,22 @@ TARGET = $$qtLibraryTarget(platformplugin)
 TEMPLATE = lib
 CONFIG += plugin
 
+## load mobilityconfig if mobility is available
+load(mobilityconfig, true)
+
+# HTML5 Media Support
+# We require QtMultimedia
+!contains(DEFINES, ENABLE_VIDEO=.) {
+    contains(MOBILITY_CONFIG, multimedia) {
+        CONFIG += mobility
+        MOBILITY += multimedia
+        DEFINES -= ENABLE_VIDEO=0
+        DEFINES += ENABLE_VIDEO=1
+        DEFINES -= ENABLE_QT_MULTIMEDIA=0
+        DEFINES += ENABLE_QT_MULTIMEDIA=1
+    }
+}
+
 DESTDIR = $$[QT_INSTALL_PLUGINS]/webkit
 
 SOURCES += \
index b8cc984a34458700be20b92f45686ee857240320..2a94e0cd8cfac87585473d0bcf946c101bca3f40 100644 (file)
@@ -28,6 +28,9 @@
 
 #include <QObject>
 #include <QUrl>
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+#include <QMediaPlayer>
+#endif
 
 class QWebSelectData
 {
@@ -115,6 +118,23 @@ public:
     virtual unsigned hitTestPaddingForTouch(const PaddingDirection) const = 0;
 };
 
+#if defined(ENABLE_QT_MULTIMEDIA) && ENABLE_QT_MULTIMEDIA
+class QWebFullScreenVideoHandler : public QObject {
+    Q_OBJECT
+public:
+    QWebFullScreenVideoHandler() {}
+    virtual ~QWebFullScreenVideoHandler() {}
+    virtual bool requiresFullScreenForVideoPlayback() const = 0;
+
+Q_SIGNALS:
+    void fullScreenClosed();
+
+public Q_SLOTS:
+    virtual void enterFullScreen(QMediaPlayer*) = 0;
+    virtual void exitFullScreen() = 0;
+};
+#endif
+
 class QWebKitPlatformPlugin
 {
 public:
@@ -124,7 +144,8 @@ public:
         MultipleSelections,
         Notifications,
         Haptics,
-        TouchInteraction
+        TouchInteraction,
+        FullScreenVideoPlayer
     };
 
     virtual bool supportsExtension(Extension extension) const = 0;
@@ -132,7 +153,7 @@ public:
 };
 
 QT_BEGIN_NAMESPACE
-Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.6");
+Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.7");
 QT_END_NAMESPACE
 
 #endif // QWEBKITPLATFORMPLUGIN_H