2011-04-06 Alexis Menard <alexis.menard@openbossa.org>
[WebKit-https.git] / Source / WebKit / qt / WebCoreSupport / ChromeClientQt.cpp
index fb9b96c21f1b6771aba62e8d79a28d8d4d79dc25..083593ca169abf89f1a8a3d72aa63053490e7073 100644 (file)
 #include <qtooltip.h>
 #include <wtf/OwnPtr.h>
 
-#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+#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 {
 
@@ -90,7 +92,7 @@ bool ChromeClientQt::dumpVisitedLinksCallbacks = false;
 ChromeClientQt::ChromeClientQt(QWebPage* webPage)
     : m_webPage(webPage)
     , m_eventLoop(0)
-#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+#if ENABLE(VIDEO)
     , m_fullScreenVideo(0)
 #endif
 {
@@ -102,7 +104,7 @@ ChromeClientQt::~ChromeClientQt()
     if (m_eventLoop)
         m_eventLoop->exit();
 
-#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+#if ENABLE(VIDEO)
     delete m_fullScreenVideo;
 #endif
 }
@@ -354,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
@@ -410,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.
@@ -429,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
 
@@ -648,7 +652,7 @@ IntRect ChromeClientQt::visibleRectForTiledBackingStore() const
 }
 #endif
 
-#if ENABLE(VIDEO) && ENABLE(QT_MULTIMEDIA)
+#if ENABLE(VIDEO)
 FullScreenVideoQt* ChromeClientQt::fullScreenVideo()
 {
     if (!m_fullScreenVideo)
@@ -671,13 +675,6 @@ 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);
 }
 
@@ -685,13 +682,6 @@ 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