2011-02-10 Alexis Menard <alexis.menard@nokia.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Feb 2011 18:15:37 +0000 (18:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Feb 2011 18:15:37 +0000 (18:15 +0000)
        Reviewed by Andreas Kling.

        [Qt] In trunk with Qt Multimedia the full screen mode doesn't work.
        https://bugs.webkit.org/show_bug.cgi?id=54201

        Add files for the fullscreen video playback handling. It also fix
        a missing header.

        * WebCore.pro:
2011-02-10  Alexis Menard  <alexis.menard@nokia.com>

        Reviewed by Andreas Kling.

        [Qt] In trunk with Qt Multimedia the full screen mode doesn't work.
        https://bugs.webkit.org/show_bug.cgi?id=54201

        Add a default fullscreen handler when there is no plaftform plugin
        installed. This handler creates a fullscreen QVideoWidget and plays
        the video. Space pause/resume the video playback and esc quit the
        fullscreen mode.

        * WebCoreSupport/FullScreenVideoQt.cpp:
        (WebCore::DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler):
        (WebCore::DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler):
        (WebCore::DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback):
        (WebCore::DefaultFullScreenVideoHandler::enterFullScreen):
        (WebCore::DefaultFullScreenVideoHandler::exitFullScreen):
        (WebCore::FullScreenVideoQt::FullScreenVideoQt):
        * WebCoreSupport/FullScreenVideoQt.h:
        * WebCoreSupport/FullScreenVideoWidget.cpp: Added.
        (WebCore::FullScreenVideoWidget::FullScreenVideoWidget):
        (WebCore::FullScreenVideoWidget::~FullScreenVideoWidget):
        (WebCore::FullScreenVideoWidget::show):
        (WebCore::FullScreenVideoWidget::closeEvent):
        (WebCore::FullScreenVideoWidget::event):
        (WebCore::FullScreenVideoWidget::keyPressEvent):
        (WebCore::FullScreenVideoWidget::hideCursor):
        (WebCore::FullScreenVideoWidget::showCursor):
        * WebCoreSupport/FullScreenVideoWidget.h: Added.

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.pro
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp
Source/WebKit/qt/WebCoreSupport/FullScreenVideoQt.h
Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp [new file with mode: 0644]
Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h [new file with mode: 0644]

index 309e5f6e285995b3542ae22babc71d8a0234ee5a..c7bf3f94206927d848e1352ddc7329eecf08fea5 100644 (file)
@@ -1,3 +1,15 @@
+2011-02-10  Alexis Menard  <alexis.menard@nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        [Qt] In trunk with Qt Multimedia the full screen mode doesn't work.
+        https://bugs.webkit.org/show_bug.cgi?id=54201
+
+        Add files for the fullscreen video playback handling. It also fix
+        a missing header.
+
+        * WebCore.pro:
+
 2011-02-09  Pavel Feldman  <pfeldman@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index 88522abf214e6277c0ff7b315d000b9deb7720f1..7bf40189264629c2fa383b682211d5f83459d810 100644 (file)
@@ -2677,6 +2677,7 @@ HEADERS += \
     $$PWD/../WebKit/qt/Api/qwebplugindatabase_p.h \
     $$PWD/../WebKit/qt/WebCoreSupport/InspectorServerQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/QtFallbackWebPopup.h \
+    $$PWD/../WebKit/qt/WebCoreSupport/ChromeClientQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/FrameNetworkingContextQt.h \
     $$PWD/../WebKit/qt/WebCoreSupport/GeolocationPermissionClientQt.h \
@@ -3282,11 +3283,13 @@ contains(DEFINES, ENABLE_VIDEO=1) {
      } else:contains(MOBILITY_CONFIG, multimedia) {
         HEADERS += \ 
             platform/graphics/qt/MediaPlayerPrivateQt.h \
-            $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoQt.h
+            $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoQt.h \
+            $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h
 
         SOURCES += \
             platform/graphics/qt/MediaPlayerPrivateQt.cpp \
-            $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp
+            $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoQt.cpp \
+            $$PWD/../WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp
 
         CONFIG *= mobility
         MOBILITY += multimedia
index 0b78886104f0a121437a365c9f5d1491af66f0cb..229f6ed4363ae9186b4acee4fce4dff117596460 100644 (file)
@@ -1,3 +1,34 @@
+2011-02-10  Alexis Menard  <alexis.menard@nokia.com>
+
+        Reviewed by Andreas Kling.
+
+        [Qt] In trunk with Qt Multimedia the full screen mode doesn't work.
+        https://bugs.webkit.org/show_bug.cgi?id=54201
+
+        Add a default fullscreen handler when there is no plaftform plugin
+        installed. This handler creates a fullscreen QVideoWidget and plays
+        the video. Space pause/resume the video playback and esc quit the
+        fullscreen mode.
+
+        * WebCoreSupport/FullScreenVideoQt.cpp:
+        (WebCore::DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler):
+        (WebCore::DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler):
+        (WebCore::DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback):
+        (WebCore::DefaultFullScreenVideoHandler::enterFullScreen):
+        (WebCore::DefaultFullScreenVideoHandler::exitFullScreen):
+        (WebCore::FullScreenVideoQt::FullScreenVideoQt):
+        * WebCoreSupport/FullScreenVideoQt.h:
+        * WebCoreSupport/FullScreenVideoWidget.cpp: Added.
+        (WebCore::FullScreenVideoWidget::FullScreenVideoWidget):
+        (WebCore::FullScreenVideoWidget::~FullScreenVideoWidget):
+        (WebCore::FullScreenVideoWidget::show):
+        (WebCore::FullScreenVideoWidget::closeEvent):
+        (WebCore::FullScreenVideoWidget::event):
+        (WebCore::FullScreenVideoWidget::keyPressEvent):
+        (WebCore::FullScreenVideoWidget::hideCursor):
+        (WebCore::FullScreenVideoWidget::showCursor):
+        * WebCoreSupport/FullScreenVideoWidget.h: Added.
+
 2011-02-10  kasthuri  <kasthuri.n-s@nokia.com>
 
         Reviewed by Antonio Gomes.
index bdc22e52f3345867802e2bb671db843dc31c5e42..ccca43c7d3a13726ffb033969d89cfad361cd0b3 100644 (file)
 #include "FullScreenVideoQt.h"
 
 #include "ChromeClientQt.h"
+#include "FullScreenVideoWidget.h"
 #include "HTMLNames.h"
 #include "HTMLVideoElement.h"
 #include "MediaPlayerPrivateQt.h"
 #include "Node.h"
-#include "qwebkitplatformplugin.h"
+
 
 #include <QGraphicsVideoItem>
+#include <QMediaPlayer>
 
 namespace WebCore {
 
+bool DefaultFullScreenVideoHandler::s_shouldForceFullScreenVideoPlayback = false;
+
+DefaultFullScreenVideoHandler::DefaultFullScreenVideoHandler()
+    : QWebFullScreenVideoHandler()
+    , m_fullScreenWidget(new FullScreenVideoWidget)
+{
+    connect(m_fullScreenWidget, SIGNAL(didExitFullScreen()), this, SIGNAL(fullScreenClosed()));
+    m_fullScreenWidget->hide();
+}
+
+DefaultFullScreenVideoHandler::~DefaultFullScreenVideoHandler()
+{
+    delete m_fullScreenWidget;
+}
+
+bool DefaultFullScreenVideoHandler::requiresFullScreenForVideoPlayback() const
+{
+    static bool initialized = false;
+    if (!initialized) {
+        QByteArray forceFullScreen = qgetenv("QT_WEBKIT_FORCE_FULLSCREEN_VIDEO");
+        if (!forceFullScreen.isEmpty())
+            s_shouldForceFullScreenVideoPlayback = true;
+
+        initialized = true;
+    }
+
+    return s_shouldForceFullScreenVideoPlayback;
+}
+
+void DefaultFullScreenVideoHandler::enterFullScreen(QMediaPlayer* player)
+{
+    m_fullScreenWidget->show(player);
+}
+
+void DefaultFullScreenVideoHandler::exitFullScreen()
+{
+    m_fullScreenWidget->close();
+}
+
 FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient)
     : m_chromeClient(chromeClient)
     , m_videoElement(0)
@@ -39,6 +80,9 @@ FullScreenVideoQt::FullScreenVideoQt(ChromeClientQt* chromeClient)
     Q_ASSERT(m_chromeClient);
     m_FullScreenVideoHandler = m_chromeClient->m_platformPlugin.createFullScreenVideoHandler();
 
+    if (!m_FullScreenVideoHandler)
+        m_FullScreenVideoHandler = new DefaultFullScreenVideoHandler;
+
     if (m_FullScreenVideoHandler)
         connect(m_FullScreenVideoHandler, SIGNAL(fullScreenClosed()), this, SLOT(aboutToClose()));
 }
index 637da70a27c98ee6a9c714f48a57e436b45d20a9..a48a882c45a47d9715f5178236864e2501e60cbd 100644 (file)
 #ifndef FullScreenVideoQt_h
 #define FullScreenVideoQt_h
 
+#include "qwebkitplatformplugin.h"
 #include <QObject>
 
 QT_BEGIN_NAMESPACE
 class QGraphicsVideoItem;
+class QMediaPlayer;
 QT_END_NAMESPACE
 
-class QWebFullScreenVideoHandler;
-
 namespace WebCore {
 
 class ChromeClientQt;
+class FullScreenVideoWidget;
 class HTMLVideoElement;
 class Node;
 class MediaPlayerPrivateQt;
 
+class DefaultFullScreenVideoHandler : public QWebFullScreenVideoHandler {
+    Q_OBJECT
+public:
+    DefaultFullScreenVideoHandler();
+    virtual ~DefaultFullScreenVideoHandler();
+    bool requiresFullScreenForVideoPlayback() const;
+
+public Q_SLOTS:
+    void enterFullScreen(QMediaPlayer*);
+    void exitFullScreen();
+
+private:
+    static bool s_shouldForceFullScreenVideoPlayback;
+    FullScreenVideoWidget *m_fullScreenWidget;
+};
+
 class FullScreenVideoQt : public QObject {
     Q_OBJECT
 public:
@@ -61,4 +78,4 @@ private:
 
 }
 
-#endif // PopupMenuQt_h
+#endif // FullScreenVideoQt_h
diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.cpp
new file mode 100644 (file)
index 0000000..4922cd7
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "FullScreenVideoWidget.h"
+
+#include <QApplication>
+#include <QCloseEvent>
+#include <QDesktopWidget>
+#include <QKeyEvent>
+#include <QMediaPlayer>
+
+static const int gHideMouseCursorDelay = 3000;
+
+namespace WebCore {
+
+FullScreenVideoWidget::FullScreenVideoWidget()
+    : QVideoWidget()
+    , m_mediaPlayer(0)
+{
+    QPalette palette(this->palette());
+    palette.setColor(QPalette::Base, Qt::black);
+    palette.setColor(QPalette::Background, Qt::black);
+    setPalette(palette);
+
+    setWindowModality(Qt::ApplicationModal);
+    setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
+
+    setGeometry(QApplication::desktop()->screenGeometry());
+
+    m_cursorTimer.setSingleShot(true);
+    connect(&m_cursorTimer, SIGNAL(timeout()), this, SLOT(hideCursor()));
+}
+
+FullScreenVideoWidget::~FullScreenVideoWidget()
+{
+}
+
+void FullScreenVideoWidget::show(QMediaPlayer* player)
+{
+    m_mediaPlayer = player;
+    showFullScreen();
+    setMouseTracking(true);
+    raise();
+    m_mediaPlayer->setVideoOutput(this);
+    grabMouse();
+    hideCursor();
+}
+
+void FullScreenVideoWidget::closeEvent(QCloseEvent* event)
+{
+    m_mediaPlayer = 0;
+    setMouseTracking(false);
+    releaseMouse();
+    QApplication::restoreOverrideCursor();
+    event->ignore();
+    hide();
+    emit didExitFullScreen();
+}
+
+bool FullScreenVideoWidget::event(QEvent* ev)
+{
+    switch (ev->type()) {
+    case QEvent::MouseMove:
+        showCursor();
+        ev->accept();
+        return true;
+    case QEvent::MouseButtonDblClick:
+        close();
+        ev->accept();
+        return true;
+    default:
+        return QVideoWidget::event(ev);
+    }
+}
+
+void FullScreenVideoWidget::keyPressEvent(QKeyEvent* ev)
+{
+    if (m_mediaPlayer && ev->key() == Qt::Key_Space) {
+        if (m_mediaPlayer->state() == QMediaPlayer::PlayingState)
+            m_mediaPlayer->pause();
+        else
+            m_mediaPlayer->play();
+    } else if (ev->key() == Qt::Key_Escape)
+        close();
+}
+
+void FullScreenVideoWidget::hideCursor()
+{
+    QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
+}
+
+void FullScreenVideoWidget::showCursor()
+{
+    QApplication::restoreOverrideCursor();
+    m_cursorTimer.start(gHideMouseCursorDelay);
+}
+
+}
diff --git a/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h b/Source/WebKit/qt/WebCoreSupport/FullScreenVideoWidget.h
new file mode 100644 (file)
index 0000000..466042c
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FullScreenVideoWidget_h
+#define FullScreenVideoWidget_h
+
+#include <QTimer>
+#include <QVideoWidget>
+
+QT_BEGIN_NAMESPACE
+class QMediaPlayer;
+QT_END_NAMESPACE
+
+namespace WebCore {
+
+class FullScreenVideoWidget : public QVideoWidget {
+    Q_OBJECT
+public:
+    FullScreenVideoWidget();
+    virtual ~FullScreenVideoWidget();
+    void show(QMediaPlayer*);
+
+Q_SIGNALS:
+    void didExitFullScreen();
+
+protected:
+    virtual void closeEvent(QCloseEvent*);
+    virtual bool event(QEvent*);
+    virtual void keyPressEvent(QKeyEvent*);
+
+private slots:
+    void hideCursor();
+
+private:
+    void showCursor();
+    QMediaPlayer* m_mediaPlayer;
+    QTimer m_cursorTimer;
+};
+
+}
+
+#endif // FullScreenVideoWidget_h