2011-04-06 Alexis Menard <alexis.menard@openbossa.org>
[WebKit-https.git] / Source / WebKit / qt / WebCoreSupport / ChromeClientQt.cpp
index 6116ae77860e0d45fa25f42b03541a70bde0084d..083593ca169abf89f1a8a3d72aa63053490e7073 100644 (file)
@@ -42,7 +42,6 @@
 #if USE(ACCELERATED_COMPOSITING)
 #include "GraphicsLayer.h"
 #endif
-#include "GeolocationPermissionClientQt.h"
 #include "HitTestResult.h"
 #include "Icon.h"
 #include "NavigationAction.h"
 #include <qtooltip.h>
 #include <wtf/OwnPtr.h>
 
+#if ENABLE(VIDEO)
+#include "FullScreenVideoQt.h"
+#include "HTMLMediaElement.h"
+#include "HTMLNames.h"
+#include "HTMLVideoElement.h"
+#if USE(QT_MULTIMEDIA)
+#include "MediaPlayerPrivateQt.h"
+#endif
+#endif
+
 namespace WebCore {
 
 bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
@@ -83,6 +92,9 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
 ChromeClientQt::ChromeClientQt(QWebPage* webPage)
     : m_webPage(webPage)
     , m_eventLoop(0)
+#if ENABLE(VIDEO)
+    , m_fullScreenVideo(0)
+#endif
 {
     toolBarsVisible = statusBarVisible = menuBarVisible = true;
 }
@@ -91,6 +103,10 @@ ChromeClientQt::~ChromeClientQt()
 {
     if (m_eventLoop)
         m_eventLoop->exit();
+
+#if ENABLE(VIDEO)
+    delete m_fullScreenVideo;
+#endif
 }
 
 void ChromeClientQt::setWindowRect(const FloatRect& rect)
@@ -292,6 +308,7 @@ bool ChromeClientQt::runBeforeUnloadConfirmPanel(const String& message, Frame* f
 
 void ChromeClientQt::closeWindowSoon()
 {
+    m_webPage->d->page->setGroupName(String());
     m_webPage->mainFrame()->d->frame->loader()->stopAllLoaders();
     emit m_webPage->windowCloseRequested();
 }
@@ -339,9 +356,10 @@ bool ChromeClientQt::shouldInterruptJavaScript()
     return shouldInterrupt;
 }
 
-bool ChromeClientQt::tabsToLinks() const
+KeyboardUIMode ChromeClientQt::keyboardUIMode()
 {
-    return m_webPage->settings()->testAttribute(QWebSettings::LinksIncludedInFocusChain);
+    return m_webPage->settings()->testAttribute(QWebSettings::LinksIncludedInFocusChain)
+        ? KeyboardAccessTabsToLinks : KeyboardAccessDefault;
 }
 
 IntRect ChromeClientQt::windowResizerRect() const
@@ -395,7 +413,7 @@ void ChromeClientQt::invalidateContentsAndWindow(const IntRect& windowRect, bool
         if (!rect.isEmpty())
             platformPageClient()->update(rect);
     }
-    emit m_webPage->repaintRequested(windowRect);
+    QMetaObject::invokeMethod(m_webPage, "repaintRequested", Qt::QueuedConnection, Q_ARG(QRect, windowRect));
 
     // FIXME: There is no "immediate" support for window painting.  This should be done always whenever the flag
     // is set.
@@ -414,9 +432,10 @@ void ChromeClientQt::scroll(const IntSize& delta, const IntRect& scrollViewRect,
 }
 
 #if ENABLE(TILED_BACKING_STORE)
-void ChromeClientQt::delegatedScrollRequested(const IntSize& delta)
+void ChromeClientQt::delegatedScrollRequested(const IntPoint& point)
 {
-    emit m_webPage->scrollRequested(delta.width(), delta.height(), QRect(QPoint(0, 0), m_webPage->viewportSize()));
+    QPoint currentPosition(m_webPage->mainFrame()->scrollPosition());
+    emit m_webPage->scrollRequested(point.x() - currentPosition.x(), point.y() - currentPosition.y(), QRect(QPoint(0, 0), m_webPage->viewportSize()));
 }
 #endif
 
@@ -588,21 +607,6 @@ void ChromeClientQt::setCursor(const Cursor& cursor)
 #endif
 }
 
-void ChromeClientQt::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
-{
-#if ENABLE(GEOLOCATION)
-    QWebFrame* webFrame = QWebFramePrivate::kit(frame);
-    GeolocationPermissionClientQt::geolocationPermissionClient()->requestGeolocationPermissionForFrame(webFrame, geolocation);
-#endif
-}
-
-void ChromeClientQt::cancelGeolocationPermissionRequestForFrame(Frame* frame, Geolocation* geolocation)
-{
-#if ENABLE(GEOLOCATION)
-    QWebFrame* webFrame = QWebFramePrivate::kit(frame);
-    GeolocationPermissionClientQt::geolocationPermissionClient()->cancelGeolocationPermissionRequestForFrame(webFrame, geolocation);
-#endif
-}
 
 #if USE(ACCELERATED_COMPOSITING)
 void ChromeClientQt::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
@@ -648,6 +652,40 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
 }
 #endif
 
+#if ENABLE(VIDEO)
+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));
+
+    fullScreenVideo()->enterFullScreenForNode(node);
+}
+
+void ChromeClientQt::exitFullscreenForNode(Node* node)
+{
+    ASSERT(node && node->hasTagName(HTMLNames::videoTag));
+
+    fullScreenVideo()->exitFullScreenForNode(node);
+} 
+#endif
+
 QWebSelectMethod* ChromeClientQt::createSelectPopup() const
 {
     QWebSelectMethod* result = m_platformPlugin.createSelectInputMethod();
@@ -673,6 +711,11 @@ bool ChromeClientQt::selectItemWritingDirectionIsNatural()
     return false;
 }
 
+bool ChromeClientQt::selectItemAlignmentFollowsMenuWritingDirection()
+{
+    return false;
+}
+
 PassRefPtr<PopupMenu> ChromeClientQt::createPopupMenu(PopupMenuClient* client) const
 {
     return adoptRef(new PopupMenuQt(client, this));