[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

commit-queue at webkit.org commit-queue at webkit.org
Sun Feb 20 23:06:23 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit cc90609f9640af346c1e2fe10ac7430ce4837989
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 17 16:00:31 2011 +0000

    2011-01-17  Yi Shen  <yi.4.shen at 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  Yi Shen  <yi.4.shen at 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: http://svn.webkit.org/repository/webkit/trunk@75944 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 89ee8c0..bffb3d7 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2011-01-17  Yi Shen  <yi.4.shen at 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 at webkit.org>
 
         Reviewed by Kent Tamura.
diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro
index 7af008c..b37bf45 100644
--- a/Source/WebCore/WebCore.pro
+++ b/Source/WebCore/WebCore.pro
@@ -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
diff --git a/Source/WebCore/features.pri b/Source/WebCore/features.pri
index ff54b14..fdf11ed 100644
--- a/Source/WebCore/features.pri
+++ b/Source/WebCore/features.pri
@@ -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
     }
 }
 
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
index dd4b6e6..be6f732 100644
--- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp
@@ -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)
diff --git a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
index 93c9d1c..2621432 100644
--- a/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
+++ b/Source/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h
@@ -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;
diff --git a/Source/WebKit/qt/Api/qwebkitplatformplugin.h b/Source/WebKit/qt/Api/qwebkitplatformplugin.h
index b8cc984..2a94e0c 100644
--- a/Source/WebKit/qt/Api/qwebkitplatformplugin.h
+++ b/Source/WebKit/qt/Api/qwebkitplatformplugin.h
@@ -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
diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog
index 26394ec..7ccb0d4 100644
--- a/Source/WebKit/qt/ChangeLog
+++ b/Source/WebKit/qt/ChangeLog
@@ -1,3 +1,56 @@
+2011-01-17  Yi Shen  <yi.4.shen at 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 at webkit.org>
 
         Rubber-stamped by Eric Seidel.
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index 6116ae7..acb136a 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -76,6 +76,14 @@
 #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();
diff --git a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
index bcf8975..d8c2f57 100644
--- a/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
+++ b/Source/WebKit/qt/WebCoreSupport/ChromeClientQt.h
@@ -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
index 0000000..bdc22e5
--- /dev/null
+++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp
@@ -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
index 0000000..637da70
--- /dev/null
+++ b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h
@@ -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
diff --git a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
index e4b89b4..ea56134 100644
--- a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
+++ b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
@@ -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
+
 }
diff --git a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
index 365b734..71ee2bb 100644
--- a/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
+++ b/Source/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
@@ -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();
 
diff --git a/Source/WebKit/qt/examples/platformplugin/WebPlugin.cpp b/Source/WebKit/qt/examples/platformplugin/WebPlugin.cpp
index d029b73..320079f 100644
--- a/Source/WebKit/qt/examples/platformplugin/WebPlugin.cpp
+++ b/Source/WebKit/qt/examples/platformplugin/WebPlugin.cpp
@@ -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;
     }
diff --git a/Source/WebKit/qt/examples/platformplugin/WebPlugin.h b/Source/WebKit/qt/examples/platformplugin/WebPlugin.h
index 0243f57..4994669 100644
--- a/Source/WebKit/qt/examples/platformplugin/WebPlugin.h
+++ b/Source/WebKit/qt/examples/platformplugin/WebPlugin.h
@@ -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
diff --git a/Source/WebKit/qt/examples/platformplugin/platformplugin.pro b/Source/WebKit/qt/examples/platformplugin/platformplugin.pro
index 9275665..ccc0b3a 100644
--- a/Source/WebKit/qt/examples/platformplugin/platformplugin.pro
+++ b/Source/WebKit/qt/examples/platformplugin/platformplugin.pro
@@ -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 += \
diff --git a/Source/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h b/Source/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h
index b8cc984..2a94e0c 100644
--- a/Source/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h
+++ b/Source/WebKit/qt/examples/platformplugin/qwebkitplatformplugin.h
@@ -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

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list