Bug 677712 - Make Qt port support No X11 build; r=dougt,joe
authorOleg Romashin <romaxa@gmail.com>
Wed, 24 Aug 2011 17:15:58 +0100
changeset 76866 206ab0f10adf0e078a2543aa3de42844725af676
parent 76865 f2bc0f9336615fe44dc7e41ed918b5896febb5e1
child 76867 22e2f80c2983978e9d2a6ef5b131bc75e8913263
push id340
push userclegnitto@mozilla.com
push dateTue, 08 Nov 2011 22:56:33 +0000
treeherdermozilla-beta@f745dc151615 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt, joe
bugs677712
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 677712 - Make Qt port support No X11 build; r=dougt,joe
configure.in
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/plugins/base/nsPluginNativeWindowQt.cpp
dom/plugins/ipc/Makefile.in
dom/plugins/ipc/NPEventUnix.h
dom/plugins/ipc/NPEventX11.h
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginMessageUtils.h
dom/plugins/test/testplugin/nptest_qt.cpp
gfx/thebes/GLContextProviderEGL.cpp
gfx/thebes/Makefile.in
gfx/thebes/gfxQtPlatform.cpp
widget/src/qt/Makefile.in
widget/src/qt/nsIdleServiceQt.cpp
widget/src/qt/nsIdleServiceQt.h
widget/src/qt/nsToolkit.cpp
widget/src/qt/nsWindow.cpp
widget/src/qt/nsWindow.h
--- a/configure.in
+++ b/configure.in
@@ -5108,25 +5108,24 @@ then
     MOZ_ARG_WITH_STRING(qtdir,
     [  --with-qtdir=\$dir       Specify Qt directory ],
     [ QTDIR=$withval])
 
     if test -z "$QTDIR"; then
         PKG_CHECK_MODULES(MOZ_QT, QtGui QtNetwork QtCore QtOpenGL)
         AC_CHECK_PROGS(HOST_MOC, $MOC moc, "")
     else
-        MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtDBus -lQtXml -lQtOpenGL"
+        MOZ_QT_LIBS="-L$QTDIR/lib/ -lQtGui -lQtNetwork -lQtCore -lQtXml -lQtOpenGL"
 
         MOZ_QT_CFLAGS="-DQT_SHARED"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/Qt"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtCore"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtNetwork"
-        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDBus"
         MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtXml"
         HOST_MOC="$QTDIR/bin/moc"
     fi
     if test -z "$HOST_MOC"; then
         AC_MSG_ERROR([No acceptable moc preprocessor found. Qt SDK is not installed or --with-qt is
 incorrect])
     fi
     MOC=$HOST_MOC
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -2005,17 +2005,17 @@ NPError NP_CALLBACK
 
   nsresult res;
 
   PluginDestructionGuard guard(npp);
 
   switch(variable) {
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
   case NPNVxDisplay : {
-#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)
+#if defined(MOZ_X11)
     if (npp) {
       nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
       PRBool windowless = PR_FALSE;
       inst->IsWindowless(&windowless);
       NPBool needXEmbed = PR_FALSE;
       if (!windowless) {
         res = inst->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed);
         // If the call returned an error code make sure we still use our default value.
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -78,18 +78,20 @@ class nsDisplayListBuilder;
 class gfxXlibSurface;
 #endif
 
 #ifdef MOZ_WIDGET_GTK2
 #include "gfxXlibNativeRenderer.h"
 #endif
 
 #ifdef MOZ_WIDGET_QT
+#ifdef MOZ_X11
 #include "gfxQtNativeRenderer.h"
 #endif
+#endif
 
 #ifdef XP_OS2
 #define INCL_PM
 #define INCL_GPI
 #include <os2.h>
 #endif
 
 // X.h defines KeyPress
--- a/dom/plugins/base/nsPluginNativeWindowQt.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowQt.cpp
@@ -72,20 +72,22 @@ nsPluginNativeWindowQt::nsPluginNativeWi
   x = 0;
   y = 0;
   width = 0;
   height = 0;
   memset(&clipRect, 0, sizeof(clipRect));
   ws_info = &mWsInfo;
   type = NPWindowTypeWindow;
   mWsInfo.type = 0;
+#if defined(MOZ_X11)
   mWsInfo.display = nsnull;
   mWsInfo.visual = nsnull;
   mWsInfo.colormap = 0;
   mWsInfo.depth = 0;
+#endif
 }
 
 nsPluginNativeWindowQt::~nsPluginNativeWindowQt()
 {
 #ifdef DEBUG
   fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this);
 #endif
 }
--- a/dom/plugins/ipc/Makefile.in
+++ b/dom/plugins/ipc/Makefile.in
@@ -54,17 +54,17 @@ EXPORTS_NAMESPACES = mozilla mozilla/plu
 
 EXPORTS_mozilla/plugins = \
   BrowserStreamChild.h \
   BrowserStreamParent.h \
   ChildAsyncCall.h \
   ChildTimer.h \
   NPEventOSX.h \
   NPEventWindows.h \
-  NPEventX11.h \
+  NPEventUnix.h \
   NPEventAndroid.h \
   PluginIdentifierChild.h \
   PluginIdentifierParent.h \
   PluginInstanceChild.h \
   PluginInstanceParent.h \
   PluginMessageUtils.h \
   PluginModuleChild.h \
   PluginModuleParent.h \
rename from dom/plugins/ipc/NPEventX11.h
rename to dom/plugins/ipc/NPEventUnix.h
--- a/dom/plugins/ipc/NPEventX11.h
+++ b/dom/plugins/ipc/NPEventUnix.h
@@ -32,22 +32,24 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef mozilla_dom_plugins_NPEventX11_h
-#define mozilla_dom_plugins_NPEventX11_h 1
+#ifndef mozilla_dom_plugins_NPEventUnix_h
+#define mozilla_dom_plugins_NPEventUnix_h 1
 
 #include "npapi.h"
 
+#ifdef MOZ_X11
 #include "mozilla/X11Util.h"
+#endif
 
 namespace mozilla {
 
 namespace plugins {
 
 struct NPRemoteEvent {
     NPEvent event;
 };
@@ -90,37 +92,42 @@ struct ParamTraits<mozilla::plugins::NPR
     {
         const char* bytes = 0;
 
         if (!aMsg->ReadBytes(aIter, &bytes, sizeof(paramType))) {
             return false;
         }
 
         memcpy(aResult, bytes, sizeof(paramType));
+
+#ifdef MOZ_X11
         SetXDisplay(aResult->event);
+#endif
         return true;
     }
 
     static void Log(const paramType& aParam, std::wstring* aLog)
     {
         // TODO
         aLog->append(L"(XEvent)");
     }
 
+#ifdef MOZ_X11
 private:
     static void SetXDisplay(XEvent& ev)
     {
         Display* display = mozilla::DefaultXDisplay();
         if (ev.type >= KeyPress) {
             ev.xany.display = display;
         }
         else {
             // XXX assuming that this is an error event
             // (type == 0? not clear from Xlib.h)
             ev.xerror.display = display;
         }
     }
+#endif
 };
 
 } // namespace IPC
 
 
 #endif // ifndef mozilla_dom_plugins_NPEventX11_h
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -1087,16 +1087,18 @@ PluginInstanceChild::AnswerNPP_SetWindow
         mShContext = nsnull;
     }
 
     if (mPluginIface->setwindow)
         (void) mPluginIface->setwindow(&mData, &mWindow);
 
 #elif defined(ANDROID)
 #  warning Need Android impl
+#elif defined(MOZ_WIDGET_QT)
+#  warning Need QT-nonX impl
 #else
 #  error Implement me for your OS
 #endif
 
     return true;
 }
 
 bool
@@ -2384,28 +2386,28 @@ PluginInstanceChild::CreateOptSurface(vo
 
     nsRefPtr<gfxASurface> retsurf;
     // Use an opaque surface unless we're transparent and *don't* have
     // a background to source from.
     gfxASurface::gfxImageFormat format =
         (mIsTransparent && !mBackground) ? gfxASurface::ImageFormatARGB32 :
                                            gfxASurface::ImageFormatRGB24;
 
+#ifdef MOZ_X11
 #if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
     // On Maemo 5, we must send the Visibility event to activate the plugin
     if (mMaemoImageRendering) {
         NPEvent pluginEvent;
         XVisibilityEvent& visibilityEvent = pluginEvent.xvisibility;
         visibilityEvent.type = VisibilityNotify;
         visibilityEvent.display = 0;
         visibilityEvent.state = VisibilityUnobscured;
         mPluginIface->event(&mData, reinterpret_cast<void*>(&pluginEvent));
     }
 #endif
-#ifdef MOZ_X11
     Display* dpy = mWsInfo.display;
     Screen* screen = DefaultScreenOfDisplay(dpy);
     if (format == gfxASurface::ImageFormatRGB24 &&
         DefaultDepth(dpy, DefaultScreen(dpy)) == 16) {
         format = gfxASurface::ImageFormatRGB16_565;
     }
 
     if (mSurfaceType == gfxASurface::SurfaceTypeXlib) {
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -269,16 +269,19 @@ PluginInstanceParent::AnswerNPN_GetValue
     HWND id;
 #elif defined(MOZ_X11)
     XID id;
 #elif defined(XP_MACOSX)
     intptr_t id;
 #elif defined(ANDROID)
 #warning Need Android impl
     int id;
+#elif defined(MOZ_WIDGET_QT)
+#  warning Need Qt non X impl
+    int id;
 #else
 #warning Implement me
 #endif
 
     *result = mNPNIface->getvalue(mNPP, NPNVnetscapeWindow, &id);
     *value = id;
     return true;
 }
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -125,17 +125,17 @@ struct NPRemoteWindow
   base::SharedMemoryHandle surfaceHandle;
 #endif
 };
 
 #ifdef XP_WIN
 typedef HWND NativeWindowHandle;
 #elif defined(MOZ_X11)
 typedef XID NativeWindowHandle;
-#elif defined(XP_MACOSX) || defined(ANDROID)
+#elif defined(XP_MACOSX) || defined(ANDROID) || defined(MOZ_WIDGET_QT)
 typedef intptr_t NativeWindowHandle; // never actually used, will always be 0
 #else
 #error Need NativeWindowHandle for this platform
 #endif
 
 #ifdef XP_WIN
 typedef base::SharedMemoryHandle WindowsSharedMemoryHandle;
 #else
@@ -882,17 +882,17 @@ struct ParamTraits<NPCoordinateSpace>
 // NB: these guards are based on those where struct NPEvent is defined
 // in npapi.h.  They should be kept in sync.
 #if defined(XP_MACOSX)
 #  include "mozilla/plugins/NPEventOSX.h"
 #elif defined(XP_WIN)
 #  include "mozilla/plugins/NPEventWindows.h"
 #elif defined(XP_OS2)
 #  error Sorry, OS/2 is not supported
-#elif defined(XP_UNIX) && defined(MOZ_X11)
-#  include "mozilla/plugins/NPEventX11.h"
 #elif defined(ANDROID)
 #  include "mozilla/plugins/NPEventAndroid.h"
+#elif defined(XP_UNIX)
+#  include "mozilla/plugins/NPEventUnix.h"
 #else
 #  error Unsupported platform
 #endif
 
 #endif /* DOM_PLUGINS_PLUGINMESSAGEUTILS_H */
--- a/dom/plugins/test/testplugin/nptest_qt.cpp
+++ b/dom/plugins/test/testplugin/nptest_qt.cpp
@@ -105,53 +105,57 @@ pluginDrawWindow(InstanceData* instanceD
   NPWindow& window = instanceData->window;
   // When we have a widget, window.x/y are meaningless since our
   // widget is always positioned correctly and we just draw into it at 0,0
   int x = instanceData->hasWidget ? 0 : window.x;
   int y = instanceData->hasWidget ? 0 : window.y;
   int width = window.width;
   int height = window.height;
 
+#ifdef MOZ_X11
   XEvent* nsEvent = (XEvent*)event;
   const XGraphicsExposeEvent& expose = nsEvent->xgraphicsexpose;
 
   QColor drawColor((QColor)instanceData->scriptableObject->drawColor);//QRgb qRgba ( int r, int g, int b, int a )
   QPixmap pixmap = QPixmap::fromX11Pixmap(expose.drawable, QPixmap::ExplicitlyShared);
 
   QRect exposeRect(expose.x, expose.y, expose.width, expose.height);
   if (instanceData->scriptableObject->drawMode == DM_SOLID_COLOR) {
     //printf("Drawing Solid\n");
     // drawing a solid color for reftests
     QPainter painter(&pixmap);
     painter.fillRect(exposeRect, drawColor);
     notifyDidPaint(instanceData);
     return;
 
   }
+#endif
 
   NPP npp = instanceData->npp;
   if (!npp)
     return;
 
   QString text (NPN_UserAgent(npp));
   if (text.isEmpty())
     return;
 
+#ifdef MOZ_X11
   //printf("Drawing Default\n");
   // drawing a solid color for reftests
   QColor color;
   QPainter painter(&pixmap);
   QRect theRect(x, y, width, height);
   QRect clipRect(QPoint(window.clipRect.left, window.clipRect.top),
                  QPoint(window.clipRect.right, window.clipRect.bottom));
   painter.setClipRect(clipRect);
   painter.fillRect(theRect, QColor(128,128,128,255));
   painter.drawRect(theRect);
   painter.drawText(QRect(theRect), Qt::AlignCenter, text);
   notifyDidPaint(instanceData);
+#endif
   return;
 }
 
 int16_t
 pluginHandleEvent(InstanceData* instanceData, void* event)
 {
 #ifdef MOZ_X11
   XEvent* nsEvent = (XEvent*)event;
--- a/gfx/thebes/GLContextProviderEGL.cpp
+++ b/gfx/thebes/GLContextProviderEGL.cpp
@@ -34,53 +34,50 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#if defined(MOZ_X11)
+#if defined(XP_UNIX)
 
 #ifdef MOZ_WIDGET_GTK2
 #include <gdk/gdkx.h>
 // we're using default display for now
 #define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)GDK_WINDOW_XID((GdkWindow *) aWidget->GetNativeData(NS_NATIVE_WINDOW))
 #elif defined(MOZ_WIDGET_QT)
-#include <QWidget>
-#include <QtOpenGL/QGLWidget>
+#include <QtOpenGL/QGLContext>
 #define GLdouble_defined 1
 // we're using default display for now
-#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->handle()
+#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->winId()
 #endif
 
+#if defined(MOZ_X11)
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include "mozilla/X11Util.h"
 #include "gfxXlibSurface.h"
-typedef Display *EGLNativeDisplayType;
-typedef Pixmap   EGLNativePixmapType;
-typedef Window   EGLNativeWindowType;
-
+#endif
+
+#if defined(ANDROID)
+/* from widget */
+#include "AndroidBridge.h"
+#define EGL_LIB "/system/lib/libEGL.so"
+#define GLES2_LIB "/system/lib/libGLESv2.so"
+#else
 #define EGL_LIB "/usr/lib/libEGL.so"
 #define GLES2_LIB "/usr/lib/libGLESv2.so"
-
-#elif defined(ANDROID)
-
-/* from widget */
-#include "AndroidBridge.h"
+#endif
 
 typedef void *EGLNativeDisplayType;
 typedef void *EGLNativePixmapType;
 typedef void *EGLNativeWindowType;
 
-#define EGL_LIB "/system/lib/libEGL.so"
-#define GLES2_LIB "/system/lib/libGLESv2.so"
-
 #elif defined(XP_WIN)
 
 #include "mozilla/Preferences.h"
 #include "nsILocalFile.h"
 
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN 1
 #endif
@@ -660,17 +657,17 @@ public:
                  GLContext *aShareContext,
                  EGLConfig aConfig,
                  EGLSurface aSurface,
                  EGLContext aContext,
                  PRBool aIsOffscreen = PR_FALSE)
         : GLContext(aFormat, aIsOffscreen, aShareContext)
         , mConfig(aConfig) 
         , mSurface(aSurface), mContext(aContext)
-        , mGLWidget(nsnull)
+        , mPlatformContext(nsnull)
         , mThebesSurface(nsnull)
         , mBound(PR_FALSE)
         , mIsPBuffer(PR_FALSE)
         , mIsDoubleBuffered(PR_FALSE)
         , mPBufferCanBindToTexture(PR_FALSE)
     {
         // any EGL contexts will always be GLESv2
         SetIsGLES2(PR_TRUE);
@@ -682,17 +679,17 @@ public:
 
     ~GLContextEGL()
     {
         MarkDestroyed();
 
         // If mGLWidget is non-null, then we've been given it by the GL context provider,
         // and it's managed by the widget implementation. In this case, We can't destroy
         // our contexts.
-        if (mGLWidget)
+        if (mPlatformContext)
             return;
 
 #ifdef DEBUG
         printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
 #endif
 
         sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
         if (mSurface) {
@@ -781,33 +778,25 @@ public:
 
     PRBool MakeCurrentImpl(PRBool aForce = PR_FALSE) {
         PRBool succeeded = PR_TRUE;
 
         // Assume that EGL has the same problem as WGL does,
         // where MakeCurrent with an already-current context is
         // still expensive.
         if (!mSurface || aForce || sEGLLibrary.fGetCurrentContext() != mContext) {
-            if (mGLWidget) {
-#ifdef MOZ_WIDGET_QT
-                static_cast<QGLWidget*>(mGLWidget)->makeCurrent();
-#else
-                succeeded = PR_FALSE;
+#ifndef MOZ_WIDGET_QT
+            if (!mSurface) {
+                EGLConfig config = CreateConfig();
+                mSurface = CreateSurfaceForWindow(NULL, config);
+            }
 #endif
-            } else {
-#ifndef MOZ_WIDGET_QT
-                if (!mSurface) {
-                    EGLConfig config = CreateConfig();
-                    mSurface = CreateSurfaceForWindow(NULL, config);
-                }
-#endif
-                succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
-                                                     mSurface, mSurface,
-                                                     mContext);
-            }
+            succeeded = sEGLLibrary.fMakeCurrent(EGL_DISPLAY(),
+                                                 mSurface, mSurface,
+                                                 mContext);
             NS_ASSERTION(succeeded, "Failed to make GL context current!");
         }
 
         return succeeded;
     }
 
 #ifdef MOZ_WIDGET_QT
     virtual PRBool
@@ -878,18 +867,18 @@ public:
                 TextureImage::ContentType aContentType,
                 PRBool aUseNearestFilter = PR_FALSE);
     // hold a reference to the given surface
     // for the lifetime of this context.
     void HoldSurface(gfxASurface *aSurf) {
         mThebesSurface = aSurf;
     }
 
-    void SetQtGLWidget(void *widget) {
-        mGLWidget = widget;
+    void SetPlatformContext(void *context) {
+        mPlatformContext = context;
     }
 
     EGLContext Context() {
         return mContext;
     }
 
     PRBool BindTex2DOffscreen(GLContext *aOffscreen);
     void UnbindTex2DOffscreen(GLContext *aOffscreen);
@@ -941,17 +930,17 @@ public:
     }
 
 protected:
     friend class GLContextProviderEGL;
 
     EGLConfig  mConfig;
     EGLSurface mSurface;
     EGLContext mContext;
-    void *mGLWidget;
+    void *mPlatformContext;
     nsRefPtr<gfxASurface> mThebesSurface;
     PRBool mBound;
 
     PRPackedBool mIsPBuffer;
     PRPackedBool mIsDoubleBuffered;
     PRPackedBool mPBufferCanBindToTexture;
 
     static EGLSurface CreatePBufferSurfaceTryingPowerOfTwo(EGLConfig config,
@@ -1091,17 +1080,17 @@ GLContextEGL::ResizeOffscreen(const gfxI
                                                                     gfxASurface::ImageFormatRGB24),
                                    aNewSize);
         // Make sure that pixmap created and ready for GL rendering
         XSync(DefaultXDisplay(), False);
 
         if (xsurface->CairoStatus() != 0) {
             return PR_FALSE;
         }
-        pixmap = xsurface->XDrawable();
+        pixmap = (EGLNativePixmapType)xsurface->XDrawable();
         if (!pixmap) {
             return PR_FALSE;
         }
 
         EGLSurface surface;
         EGLConfig config = 0;
         int depth = gfxUtils::ImageFormatToDepth(gfxPlatform::GetPlatform()->GetOffscreenFormat());
         surface = CreateEGLSurfaceForXSurface(xsurface, &config, depth);
@@ -1723,44 +1712,41 @@ DepthToGLFormat(int aDepth)
 #ifdef MOZ_WIDGET_QT
 already_AddRefed<GLContext>
 GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
         return nsnull;
     }
 
-    QWidget *viewport = static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
-    if (!viewport)
-        return nsnull;
-
-    if (viewport->paintEngine()->type() == QPaintEngine::OpenGL2) {
+    QGLContext* context = const_cast<QGLContext*>(QGLContext::currentContext());
+    if (context && context->device()) {
         // Qt widget viewport already have GL context created by Qt
         // Create dummy GLContextEGL class
         nsRefPtr<GLContextEGL> glContext =
-            new GLContextEGL(ContextFormat(DepthToGLFormat(viewport->depth())),
+            new GLContextEGL(ContextFormat(DepthToGLFormat(context->device()->depth())),
                              NULL,
                              NULL, NULL,
                              sEGLLibrary.fGetCurrentContext(),
                              PR_FALSE);
 
         if (!glContext->Init())
             return nsnull;
 
-        glContext->SetIsDoubleBuffered(PR_TRUE);
-
-        glContext->SetQtGLWidget(viewport);
+        glContext->SetIsDoubleBuffered(context->format().doubleBuffer());
+
+        glContext->SetPlatformContext(context);
 
         return glContext.forget();
     }
 
     // All Qt nsIWidget's have the same X-Window surface
     // And EGL not allowing to create multiple GL context for the same window
     // we should be able to create GL context for QGV viewport once, and reuse it for all child widgets
-    NS_ERROR("Need special GLContext implementation for QT widgets structure");
+    NS_ERROR("Failed to get QGLContext");
 
     // Switch to software rendering here
     return nsnull;
 }
 
 #else
 
 EGLConfig
@@ -2076,21 +2062,21 @@ CreateEGLSurfaceForXSurface(gfxASurface*
         LOCAL_EGL_TEXTURE_FORMAT,       LOCAL_EGL_TEXTURE_RGBA,
         LOCAL_EGL_NONE
     };
 
     EGLSurface surface = nsnull;
     if (aConfig && *aConfig) {
         if (opaque)
             surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), *aConfig,
-                                                       xsurface->XDrawable(),
+                                                       (EGLNativePixmapType)xsurface->XDrawable(),
                                                        pixmap_config_rgb);
         else
             surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), *aConfig,
-                                                       xsurface->XDrawable(),
+                                                       (EGLNativePixmapType)xsurface->XDrawable(),
                                                        pixmap_config_rgba);
 
         if (surface != EGL_NO_SURFACE)
             return surface;
     }
 
     EGLConfig configs[32];
     int numConfigs = 32;
@@ -2119,21 +2105,21 @@ CreateEGLSurfaceForXSurface(gfxASurface*
 
     if (numConfigs == 0)
         return nsnull;
 
     int i = 0;
     for (i = 0; i < numConfigs; ++i) {
         if (opaque)
             surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
-                                                       xsurface->XDrawable(),
+                                                       (EGLNativePixmapType)xsurface->XDrawable(),
                                                        pixmap_config_rgb);
         else
             surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
-                                                       xsurface->XDrawable(),
+                                                       (EGLNativePixmapType)xsurface->XDrawable(),
                                                        pixmap_config_rgba);
 
         if (surface != EGL_NO_SURFACE)
             break;
     }
 
     if (!surface) {
         return nsnull;
@@ -2162,17 +2148,17 @@ GLContextEGL::CreateEGLPixmapOffscreenCo
                                gUseBackingSurface ? aSize : gfxIntSize(16, 16));
 
     // XSync required after gfxXlibSurface::Create, otherwise EGL will fail with BadDrawable error
     XSync(DefaultXDisplay(), False);
     if (xsurface->CairoStatus() != 0)
         return nsnull;
 
     thebesSurface = xsurface;
-    pixmap = xsurface->XDrawable();
+    pixmap = (EGLNativePixmapType)xsurface->XDrawable();
 #endif
 
     if (!pixmap) {
         return nsnull;
     }
 
     EGLSurface surface = 0;
     EGLConfig config = 0;
--- a/gfx/thebes/Makefile.in
+++ b/gfx/thebes/Makefile.in
@@ -285,17 +285,19 @@ endif
 endif
 
 ifdef MOZ_DFB
 CPPSRCS += gfxDirectFBSurface.cpp
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
 CPPSRCS += gfxQtPlatform.cpp gfxQPainterSurface.cpp
+ifdef MOZ_X11
 CPPSRCS += gfxXlibSurface.cpp gfxQtNativeRenderer.cpp
+endif
 ifdef MOZ_PANGO
 CPPSRCS += gfxPangoFonts.cpp
 else
 CPPSRCS += gfxFT2Fonts.cpp
 endif
 CPPSRCS +=	gfxFT2FontBase.cpp
 CPPSRCS +=	gfxFT2Utils.cpp
 CPPSRCS +=	gfxFontconfigUtils.cpp
--- a/gfx/thebes/gfxQtPlatform.cpp
+++ b/gfx/thebes/gfxQtPlatform.cpp
@@ -77,17 +77,17 @@
 #endif
 
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 
 #define DEFAULT_RENDER_MODE RENDER_DIRECT
 
-static QPaintEngine::Type sDefaultQtPaintEngineType = QPaintEngine::X11;
+static QPaintEngine::Type sDefaultQtPaintEngineType = QPaintEngine::Raster;
 gfxFontconfigUtils *gfxQtPlatform::sFontconfigUtils = nsnull;
 static cairo_user_data_key_t cairo_qt_pixmap_key;
 static void do_qt_pixmap_unref (void *data)
 {
     QPixmap *pmap = (QPixmap*)data;
     delete pmap;
 }
 
@@ -144,17 +144,20 @@ gfxQtPlatform::gfxQtPlatform()
             break;
         default:
             mRenderMode = RENDER_QPAINTER;
     }
 
     // Qt doesn't provide a public API to detect the graphicssystem type. We hack
     // around this by checking what type of graphicssystem a test QPixmap uses.
     QPixmap pixmap(1, 1);
-    sDefaultQtPaintEngineType = pixmap.paintEngine()->type();
+#if (QT_VERSION < QT_VERSION_CHECK(4,8,0))
+    if (pixmap.paintEngine())
+        sDefaultQtPaintEngineType = pixmap.paintEngine()->type();
+#endif
 }
 
 gfxQtPlatform::~gfxQtPlatform()
 {
     gfxFontconfigUtils::Shutdown();
     sFontconfigUtils = nsnull;
 
 #ifdef MOZ_PANGO
@@ -578,14 +581,14 @@ gfxQtPlatform::GetDPI()
     QDesktopWidget* rootWindow = qApp->desktop();
     PRInt32 dpi = rootWindow->logicalDpiY(); // y-axis DPI for fonts
     return dpi <= 0 ? 96 : dpi;
 }
 
 gfxImageFormat
 gfxQtPlatform::GetOffscreenFormat()
 {
-    if (QX11Info::appDepth() == 16) {
+    if (qApp->desktop()->depth() == 16) {
         return gfxASurface::ImageFormatRGB16_565;
     }
 
     return gfxASurface::ImageFormatRGB24;
 }
--- a/widget/src/qt/Makefile.in
+++ b/widget/src/qt/Makefile.in
@@ -119,10 +119,10 @@ endif
 endif
 
 LOCAL_INCLUDES	+= \
 		   -I$(topsrcdir)/widget/src/xpwidgets \
 		   -I$(srcdir) \
 		   $(NULL)
 ifdef MOZ_X11
 INCLUDES   	+= -I$(srcdir)/../shared/x11
+endif
 INCLUDES   	+= -I$(srcdir)/../shared
-endif
--- a/widget/src/qt/nsIdleServiceQt.cpp
+++ b/widget/src/qt/nsIdleServiceQt.cpp
@@ -32,26 +32,26 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
 #include <QX11Info>
 #endif
 
 #include "nsIdleServiceQt.h"
 #include "nsIServiceManager.h"
 #include "nsDebug.h"
 #include "prlink.h"
 
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
 typedef PRBool (*_XScreenSaverQueryExtension_fn)(Display* dpy, int* event_base,
                                                  int* error_base);
 
 typedef XScreenSaverInfo* (*_XScreenSaverAllocInfo_fn)(void);
 
 typedef void (*_XScreenSaverQueryInfo_fn)(Display* dpy, Drawable drw,
                                           XScreenSaverInfo *info);
 
@@ -60,27 +60,27 @@ static _XScreenSaverAllocInfo_fn _XSSAll
 static _XScreenSaverQueryInfo_fn _XSSQueryInfo = nsnull;
 #endif
 
 static PRBool sInitialized = PR_FALSE;
 
 NS_IMPL_ISUPPORTS2(nsIdleServiceQt, nsIIdleService, nsIdleService)
 
 nsIdleServiceQt::nsIdleServiceQt()
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
     : mXssInfo(nsnull)
 #endif
 {
 }
 
 static void Initialize()
 {
     sInitialized = PR_TRUE;
 
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
     // This will leak - See comments in ~nsIdleServiceQt().
     PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1");
     if (!xsslib) {
         return;
     }
 
     _XSSQueryExtension = (_XScreenSaverQueryExtension_fn)
         PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryExtension");
@@ -88,17 +88,17 @@ static void Initialize()
         PR_FindFunctionSymbol(xsslib, "XScreenSaverAllocInfo");
     _XSSQueryInfo = (_XScreenSaverQueryInfo_fn)
         PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryInfo");
 #endif
 }
 
 nsIdleServiceQt::~nsIdleServiceQt()
 {
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
     if (mXssInfo)
         XFree(mXssInfo);
 
 // It is not safe to unload libXScrnSaver until each display is closed because
 // the library registers callbacks through XESetCloseDisplay (Bug 397607).
 // (Also the library and its functions are scoped for the file not the object.)
 #if 0
     if (xsslib) {
@@ -107,17 +107,17 @@ nsIdleServiceQt::~nsIdleServiceQt()
     }
 #endif
 #endif
 }
 
 bool
 nsIdleServiceQt::PollIdleTime(PRUint32 *aIdleTime)
 {
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
     // Ask xscreensaver about idle time:
     *aIdleTime = 0;
 
     // We might not have a display (cf. in xpcshell)
     Display *dplay = QX11Info::display();
     if (!dplay) {
         return false;
     }
@@ -143,14 +143,14 @@ nsIdleServiceQt::PollIdleTime(PRUint32 *
 #endif
 
     return false;
 }
 
 bool
 nsIdleServiceQt::UsePollMode()
 {
-#ifdef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
     return false;
 #endif
     return true;
 }
 
--- a/widget/src/qt/nsIdleServiceQt.h
+++ b/widget/src/qt/nsIdleServiceQt.h
@@ -37,17 +37,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsIdleServiceQt_h__
 #define nsIdleServiceQt_h__
 
 #include "nsIdleService.h"
 
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
 typedef struct {
     Window window;              // Screen saver window
     int state;                  // ScreenSaver(Off,On,Disabled)
     int kind;                   // ScreenSaver(Blanked,Internal,External)
     unsigned long til_or_since; // milliseconds since/til screensaver kicks in
@@ -61,17 +61,17 @@ class nsIdleServiceQt : public nsIdleSer
 public:
     NS_DECL_ISUPPORTS
     nsIdleServiceQt();
 
     bool PollIdleTime(PRUint32* aIdleTime);
 
 private:
     ~nsIdleServiceQt();
-#ifndef MOZ_PLATFORM_MAEMO
+#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
     XScreenSaverInfo* mXssInfo;
 #endif
 
 protected:
     bool UsePollMode();
 };
 
 #endif // nsIdleServiceQt_h__
--- a/widget/src/qt/nsToolkit.cpp
+++ b/widget/src/qt/nsToolkit.cpp
@@ -130,10 +130,14 @@ void nsToolkit::CreateSharedGC(void)
 
     mSharedGC = new QPixmap();
 }
 
 Qt::HANDLE
 nsToolkit::GetSharedGC(void)
 {
     // FIXME Not sure
+#ifdef MOZ_X11
     return mSharedGC->handle();
+#else
+    return 0;
+#endif
 }
--- a/widget/src/qt/nsWindow.cpp
+++ b/widget/src/qt/nsWindow.cpp
@@ -107,17 +107,19 @@ using namespace QtMobility;
 #include "nsGfxCIID.h"
 
 #include "imgIContainer.h"
 #include "nsGfxCIID.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsAutoPtr.h"
 
 #include "gfxQtPlatform.h"
+#ifdef MOZ_X11
 #include "gfxXlibSurface.h"
+#endif
 #include "gfxQPainterSurface.h"
 #include "gfxContext.h"
 #include "gfxImageSurface.h"
 
 #include "nsIDOMSimpleGestureEvent.h" //Gesture support
 
 #if MOZ_PLATFORM_MAEMO > 5
 #include "nsIDOMWindow.h"
@@ -125,16 +127,17 @@ using namespace QtMobility;
 #include "nsIFocusManager.h"
 #endif
 
 #ifdef MOZ_X11
 #include "keysym2ucs.h"
 #endif //MOZ_X11
 
 #include <QtOpenGL/QGLWidget>
+#include <QtOpenGL/QGLContext>
 #define GLdouble_defined 1
 #include "Layers.h"
 #include "LayerManagerOGL.h"
 
 #include "nsShmImage.h"
 extern "C" {
 #include "pixman.h"
 }
@@ -788,18 +791,22 @@ nsWindow::GetNativeData(PRUint32 aDataTy
     }
 
     case NS_NATIVE_PLUGIN_PORT:
         return SetupPluginPort();
         break;
 
     case NS_NATIVE_DISPLAY:
         {
+#ifdef MOZ_X11
             QWidget *widget = GetViewWidget();
             return widget ? widget->x11Info().display() : nsnull;
+#else
+            return nsnull;
+#endif
         }
         break;
 
     case NS_NATIVE_GRAPHIC: {
         NS_ASSERTION(nsnull != mToolkit, "NULL toolkit, unable to get a GC");
         return (void *)static_cast<nsToolkit *>(mToolkit)->GetSharedGC();
         break;
     }
@@ -1130,59 +1137,67 @@ nsWindow::DoPaint(QPainter* aPainter, co
 
     if (status == nsEventStatus_eIgnore)
         return status;
 
     LOGDRAW(("[%p] draw done\n", this));
 
     // Handle buffered painting mode
     if (renderMode == gfxQtPlatform::RENDER_BUFFERED) {
+#ifdef MOZ_X11
         if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
             // Paint offscreen pixmap to QPainter
             static QPixmap gBufferPixmap;
             Drawable draw = static_cast<gfxXlibSurface*>(gBufferSurface.get())->XDrawable();
             if (gBufferPixmap.handle() != draw)
                 gBufferPixmap = QPixmap::fromX11Pixmap(draw, QPixmap::ExplicitlyShared);
             XSync(static_cast<gfxXlibSurface*>(gBufferSurface.get())->XDisplay(), False);
             aPainter->drawPixmap(QPoint(rect.x, rect.y), gBufferPixmap,
                                  QRect(0, 0, rect.width, rect.height));
 
-        } else if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
+        } else
+#endif
+        if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
             // in raster mode we can just wrap gBufferImage as QImage and paint directly
             gfxImageSurface *imgs = static_cast<gfxImageSurface*>(gBufferSurface.get());
             QImage img(imgs->Data(),
                        imgs->Width(),
                        imgs->Height(),
                        imgs->Stride(),
                        _gfximage_to_qformat(imgs->Format()));
             aPainter->drawImage(QPoint(rect.x, rect.y), img,
                                 QRect(0, 0, rect.width, rect.height));
         }
     } else if (renderMode == gfxQtPlatform::RENDER_DIRECT) {
         QRect trans = aPainter->transform().mapRect(r).toRect();
+#ifdef MOZ_X11
         if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
             nsRefPtr<gfxASurface> widgetSurface = GetSurfaceForQWidget(aWidget);
             nsRefPtr<gfxContext> ctx = new gfxContext(widgetSurface);
             ctx->SetSource(gBufferSurface);
             ctx->Rectangle(gfxRect(trans.x(), trans.y(), trans.width(), trans.height()), PR_TRUE);
             ctx->Clip();
             ctx->Fill();
-        } else if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
+        } else
+#endif
+        if (gBufferSurface->GetType() == gfxASurface::SurfaceTypeImage) {
 #ifdef MOZ_HAVE_SHMIMAGE
             if (gShmImage) {
                 gShmImage->Put(aWidget, trans);
             } else
 #endif
-            if (gBufferSurface) {
-                nsRefPtr<gfxASurface> widgetSurface = GetSurfaceForQWidget(aWidget);
-                nsRefPtr<gfxContext> ctx = new gfxContext(widgetSurface);
-                ctx->SetSource(gBufferSurface);
-                ctx->Rectangle(gfxRect(trans.x(), trans.y(), trans.width(), trans.height()), PR_TRUE);
-                ctx->Clip();
-                ctx->Fill();
+            {
+                // Qt should take care about optimized rendering on QImage into painter device (gl/fb/image et.c.)
+                gfxImageSurface *imgs = static_cast<gfxImageSurface*>(gBufferSurface.get());
+                QImage img(imgs->Data(),
+                           imgs->Width(),
+                           imgs->Height(),
+                           imgs->Stride(),
+                          _gfximage_to_qformat(imgs->Format()));
+                aPainter->drawImage(trans, img, trans);
             }
         }
     }
 
     ctx = nsnull;
     targetSurface = nsnull;
 
     // check the return value!
@@ -1658,25 +1673,23 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEv
         case Qt::Key_Paste:
         case Qt::Key_F18:
         case Qt::Key_F9:
             return DispatchContentCommandEvent(NS_CONTENT_COMMAND_PASTE);
         case Qt::Key_F14:
             return DispatchContentCommandEvent(NS_CONTENT_COMMAND_UNDO);
     }
 
-#ifdef MOZ_X11
     // Qt::Key_Redo and Qt::Key_Undo are not available yet.
     if (aEvent->nativeVirtualKey() == 0xff66) {
         return DispatchContentCommandEvent(NS_CONTENT_COMMAND_REDO);
     }
     if (aEvent->nativeVirtualKey() == 0xff65) {
         return DispatchContentCommandEvent(NS_CONTENT_COMMAND_UNDO);
     }
-#endif // MOZ_X11
 
     nsKeyEvent event(PR_TRUE, NS_KEY_PRESS, this);
     InitKeyEvent(event, aEvent);
 
     // If prevent default on keydown, do same for keypress
     if (setNoDefault) {
         event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
     }
@@ -1862,17 +1875,16 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEv
 
     event.keyCode = domCharCode ? 0 : domKeyCode;
 
     if (setNoDefault)
         event.flags |= NS_EVENT_FLAG_NO_DEFAULT;
 
     // send the key press event
     return DispatchEvent(&event);
- }
 #endif
 }
 
 nsEventStatus
 nsWindow::OnKeyReleaseEvent(QKeyEvent *aEvent)
 {
     LOGFOCUS(("OnKeyReleaseEvent [%p]\n", (void *)this));
 
@@ -2297,16 +2309,17 @@ NS_IMETHODIMP
 nsWindow::SetWindowClass(const nsAString &xulWinType)
 {
     if (!mWidget)
       return NS_ERROR_FAILURE;
 
     nsXPIDLString brandName;
     GetBrandName(brandName);
 
+#ifdef MOZ_X11
     XClassHint *class_hint = XAllocClassHint();
     if (!class_hint)
       return NS_ERROR_OUT_OF_MEMORY;
     const char *role = NULL;
     class_hint->res_name = ToNewCString(xulWinType);
     if (!class_hint->res_name) {
       XFree(class_hint);
       return NS_ERROR_OUT_OF_MEMORY;
@@ -2338,16 +2351,17 @@ nsWindow::SetWindowClass(const nsAString
     if (widget && widget->handle())
         XSetClassHint(widget->x11Info().display(),
                       widget->handle(),
                       class_hint);
 
     nsMemory::Free(class_hint->res_class);
     nsMemory::Free(class_hint->res_name);
     XFree(class_hint);
+#endif
 
     return NS_OK;
 }
 
 void
 nsWindow::NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool  aRepaint)
 {
     LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this,
@@ -2520,17 +2534,19 @@ nsWindow::HideWindowChrome(PRBool aShoul
 
     // For some window managers, adding or removing window decorations
     // requires unmapping and remapping our toplevel window.  Go ahead
     // and flush the queue here so that we don't end up with a BadWindow
     // error later when this happens (when the persistence timer fires
     // and GetWindowPos is called)
     QWidget *widget = GetViewWidget();
     NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
+#ifdef MOZ_X11
     XSync(widget->x11Info().display(), False);
+#endif
 
     return NS_OK;
 }
 
 //////////////////////////////////////////////////////////////////////
 // These are all of our drag and drop operations
 
 void
@@ -2659,23 +2675,27 @@ nsWindow::createQWidget(MozQWidget *pare
             return nsnull;
         }
 
         newView->setWindowFlags(flags);
         if (mWindowType == eWindowType_dialog) {
             newView->setWindowModality(Qt::WindowModal);
         }
 
-        if (!IsAcceleratedQView(newView) && GetShouldAccelerate()) {
+#ifdef MOZ_PLATFORM_MAEMO
+        if (GetShouldAccelerate()) {
             newView->setViewport(new QGLWidget());
         }
+#endif
 
         if (gfxQtPlatform::GetPlatform()->GetRenderMode() == gfxQtPlatform::RENDER_DIRECT) {
             // Disable double buffer and system background rendering
+#ifdef MOZ_X11
             newView->viewport()->setAttribute(Qt::WA_PaintOnScreen, true);
+#endif
             newView->viewport()->setAttribute(Qt::WA_NoSystemBackground, true);
         }
         // Enable gestures:
 #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
         newView->viewport()->grabGesture(Qt::PinchGesture);
         newView->viewport()->grabGesture(gSwipeGestureId);
 #endif
         newView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -2707,26 +2727,16 @@ nsWindow::createQWidget(MozQWidget *pare
 #if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
     widget->grabGesture(Qt::PinchGesture);
     widget->grabGesture(gSwipeGestureId);
 #endif
 
     return widget;
 }
 
-PRBool
-nsWindow::IsAcceleratedQView(QGraphicsView *view)
-{
-    if (view && view->viewport()) {
-        QPaintEngine::Type type = view->viewport()->paintEngine()->type();
-        return (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2);
-    }
-    return PR_FALSE;
-}
-
 // return the gfxASurface for rendering to this widget
 gfxASurface*
 nsWindow::GetThebesSurface()
 {
     /* This is really a dummy surface; this is only used when doing reflow, because
      * we need a RenderingContext to measure text against.
      */
     if (mThebesSurface)
--- a/widget/src/qt/nsWindow.h
+++ b/widget/src/qt/nsWindow.h
@@ -344,18 +344,16 @@ private:
     void*              SetupPluginPort(void);
     nsresult           SetWindowIconList(const nsTArray<nsCString> &aIconList);
     void               SetDefaultIcon(void);
     void               InitButtonEvent(nsMouseEvent &event, QGraphicsSceneMouseEvent *aEvent, int aClickCount = 1);
     nsEventStatus      DispatchCommandEvent(nsIAtom* aCommand);
     nsEventStatus      DispatchContentCommandEvent(PRInt32 aMsg);
     MozQWidget*        createQWidget(MozQWidget *parent, nsWidgetInitData *aInitData);
 
-    PRBool             IsAcceleratedQView(QGraphicsView* aView);
-
     MozQWidget*        mWidget;
 
     PRUint32           mIsVisible : 1,
                        mActivatePending : 1;
     PRInt32            mSizeState;
     PluginType         mPluginType;
 
     nsRefPtr<gfxASurface> mThebesSurface;