diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 3682a5a83a5f..fb0b631e2488 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -306,7 +306,6 @@ def old_configure_options(*options): '--with-nss-prefix', '--with-pthreads', '--with-qemu-exe', - '--with-qtdir', '--with-servo', '--with-sixgill', '--with-soft-float', diff --git a/dom/geolocation/moz.build b/dom/geolocation/moz.build index efdfb6fd017f..2937511bc189 100644 --- a/dom/geolocation/moz.build +++ b/dom/geolocation/moz.build @@ -26,12 +26,6 @@ LOCAL_INCLUDES += [ '/dom/ipc', ] -if CONFIG['MOZ_ENABLE_QT5GEOPOSITION']: - LOCAL_INCLUDES += [ - '/dom/system/qt', - ] - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ '/dom/system/android', diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index 11b492307edc..101115f78940 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -35,10 +35,6 @@ class nsIPrincipal; -#ifdef MOZ_ENABLE_QT5GEOPOSITION -#include "QTMLocationProvider.h" -#endif - #ifdef MOZ_WIDGET_ANDROID #include "AndroidLocationProvider.h" #endif @@ -698,10 +694,6 @@ nsresult nsGeolocationService::Init() obs->AddObserver(this, "xpcom-shutdown", false); -#ifdef MOZ_ENABLE_QT5GEOPOSITION - mProvider = new QTMLocationProvider(); -#endif - #ifdef MOZ_WIDGET_ANDROID mProvider = new AndroidLocationProvider(); #endif diff --git a/dom/plugins/ipc/NestedLoopTimer.cpp b/dom/plugins/ipc/NestedLoopTimer.cpp deleted file mode 100644 index 5b20c7278117..000000000000 --- a/dom/plugins/ipc/NestedLoopTimer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include - -#include "NestedLoopTimer.h" -#include "mozilla/plugins/PluginModuleChild.h" - -namespace mozilla { -namespace plugins { - -NestedLoopTimer::NestedLoopTimer(PluginModuleChild *pmc): - QObject(), mModule(pmc), mQTimer(nullptr) -{ -} - -NestedLoopTimer::~NestedLoopTimer() -{ - if (mQTimer) { - mQTimer->stop(); - delete mQTimer; - mQTimer = nullptr; - } -} - -void NestedLoopTimer::timeOut() -{ - // just detected a nested loop; start a timer that will - // periodically rpc-call back into the browser and process some - // events - mQTimer = new QTimer(this); - QObject::connect(mQTimer, SIGNAL(timeout()), this, - SLOT(processSomeEvents())); - mQTimer->setInterval(kNestedLoopDetectorIntervalMs); - mQTimer->start(); -} - -void NestedLoopTimer::processSomeEvents() -{ - if (mModule) - mModule->CallProcessSomeEvents(); -} - -} /* namespace plugins */ -} /* namespace mozilla */ diff --git a/dom/plugins/ipc/NestedLoopTimer.h b/dom/plugins/ipc/NestedLoopTimer.h deleted file mode 100644 index 06136badb556..000000000000 --- a/dom/plugins/ipc/NestedLoopTimer.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef NESTEDLOOPTIMER_H -#define NESTEDLOOPTIMER_H - -#include - -class QTimer; - -namespace mozilla { -namespace plugins { - -class PluginModuleChild; - -class NestedLoopTimer: public QObject -{ - Q_OBJECT -public: - NestedLoopTimer(PluginModuleChild *pmc); - - virtual ~NestedLoopTimer(); - -public Q_SLOTS: - virtual void timeOut(); - virtual void processSomeEvents(); - -private: - PluginModuleChild *mModule; - QTimer *mQTimer; -}; - -} /* namespace plugins */ -} /* namespace mozilla */ - -#undef slots - -#endif diff --git a/dom/plugins/ipc/PluginHelperQt.cpp b/dom/plugins/ipc/PluginHelperQt.cpp deleted file mode 100644 index 19128edb517b..000000000000 --- a/dom/plugins/ipc/PluginHelperQt.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "PluginHelperQt.h" -#include -#include - -static const int kMaxtimeToProcessEvents = 30; - -bool -PluginHelperQt::AnswerProcessSomeEvents() -{ - QCoreApplication::processEvents(QEventLoop::AllEvents, kMaxtimeToProcessEvents); - return true; -} diff --git a/dom/plugins/ipc/moz.build b/dom/plugins/ipc/moz.build index bdba9f7617e1..046a97f48e85 100644 --- a/dom/plugins/ipc/moz.build +++ b/dom/plugins/ipc/moz.build @@ -67,13 +67,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 'PluginInterposeOSX.h', ] -if CONFIG['MOZ_ENABLE_QT']: - SOURCES += [ - '!moc_NestedLoopTimer.cpp', - 'NestedLoopTimer.cpp', - 'PluginHelperQt.cpp', - ] - UNIFIED_SOURCES += [ 'BrowserStreamChild.cpp', 'BrowserStreamParent.cpp', diff --git a/dom/plugins/test/testplugin/nptest_qt.cpp b/dom/plugins/test/testplugin/nptest_qt.cpp deleted file mode 100644 index bd2dfc412b22..000000000000 --- a/dom/plugins/test/testplugin/nptest_qt.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * - * Copyright (c) 2008, Mozilla Corporation - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * 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. - * * Neither the name of the Mozilla Corporation nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT OWNER 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. - * - * Contributor(s): - * Josh Aas - * - * ***** END LICENSE BLOCK ***** */ -#include "nptest_platform.h" -#include "npapi.h" - -using namespace std; - -bool -pluginSupportsWindowMode() -{ - return false; -} - -bool -pluginSupportsWindowlessMode() -{ - return true; -} - -NPError -pluginInstanceInit(InstanceData* instanceData) -{ - printf("NPERR_INCOMPATIBLE_VERSION_ERROR\n"); - return NPERR_INCOMPATIBLE_VERSION_ERROR; -} - -void -pluginInstanceShutdown(InstanceData* instanceData) -{ - NPN_MemFree(instanceData->platformData); - instanceData->platformData = 0; -} - -void -pluginDoSetWindow(InstanceData* instanceData, NPWindow* newWindow) -{ - instanceData->window = *newWindow; -} - -void -pluginWidgetInit(InstanceData* instanceData, void* oldWindow) -{ - // XXX nothing here yet since we don't support windowed plugins -} - -int16_t -pluginHandleEvent(InstanceData* instanceData, void* event) -{ - return 0; -} - -int32_t pluginGetEdge(InstanceData* instanceData, RectEdge edge) -{ - // XXX nothing here yet since we don't support windowed plugins - return NPTEST_INT32_ERROR; -} - -int32_t pluginGetClipRegionRectCount(InstanceData* instanceData) -{ - // XXX nothing here yet since we don't support windowed plugins - return NPTEST_INT32_ERROR; -} - -int32_t pluginGetClipRegionRectEdge(InstanceData* instanceData, - int32_t rectIndex, RectEdge edge) -{ - // XXX nothing here yet since we don't support windowed plugins - return NPTEST_INT32_ERROR; -} - -void pluginDoInternalConsistencyCheck(InstanceData* instanceData, string& error) -{ -} diff --git a/dom/plugins/test/testplugin/testplugin.mozbuild b/dom/plugins/test/testplugin/testplugin.mozbuild index 41af11b73d8f..52d3ab77fb3c 100644 --- a/dom/plugins/test/testplugin/testplugin.mozbuild +++ b/dom/plugins/test/testplugin/testplugin.mozbuild @@ -26,10 +26,6 @@ elif toolkit == 'android': UNIFIED_SOURCES += [ 'nptest_droid.cpp', ] -elif toolkit == 'qt': - UNIFIED_SOURCES += [ - 'nptest_qt.cpp', - ] elif toolkit == 'windows': UNIFIED_SOURCES += [ 'nptest_windows.cpp', @@ -61,13 +57,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'): OS_LIBS += CONFIG['XLIBS'] OS_LIBS += CONFIG['XEXT_LIBS'] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] - CFLAGS += CONFIG['MOZ_QT_CFLAGS'] - OS_LIBS += CONFIG['MOZ_QT_LIBS'] - OS_LIBS += CONFIG['XLDFLAGS'] - OS_LIBS += CONFIG['XLIBS'] - if CONFIG['_MSC_VER']: # This is intended as a temporary hack to support building with VS2015. # conversion from 'X' to 'Y' requires a narrowing conversion diff --git a/dom/system/qt/QTMLocationProvider.cpp b/dom/system/qt/QTMLocationProvider.cpp deleted file mode 100644 index 58fcc2e50743..000000000000 --- a/dom/system/qt/QTMLocationProvider.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "QTMLocationProvider.h" -#include "nsGeoPosition.h" - -using namespace mozilla; - -NS_IMPL_ISUPPORTS(QTMLocationProvider, nsIGeolocationProvider) - -QTMLocationProvider::QTMLocationProvider() -{ - if (QMetaType::type("QGeoPositionInfo") == QMetaType::UnknownType) { - qRegisterMetaType("QGeoPositionInfo"); - } - mLocation = QGeoPositionInfoSource::createDefaultSource(this); - if (mLocation) - connect(mLocation, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); -} - -QTMLocationProvider::~QTMLocationProvider() -{ - delete mLocation; -} - -void -QTMLocationProvider::positionUpdated(const QGeoPositionInfo &geoPosition) -{ - if (!geoPosition.isValid()) { - NS_WARNING("Invalida geoposition received"); - return; - } - - QGeoCoordinate coord = geoPosition.coordinate(); - double latitude = coord.latitude(); - double longitude = coord.longitude(); - double altitude = coord.altitude(); - double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy); - double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy); - double heading = geoPosition.attribute(QGeoPositionInfo::Direction); - - bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed); - double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed); - - RefPtr p = - new nsGeoPosition(latitude, longitude, - altitude, accuracy, - altitudeAccuracy, heading, - speed, geoPosition.timestamp().toTime_t()); - if (mCallback) { - mCallback->Update(p); - } -} - -NS_IMETHODIMP -QTMLocationProvider::Startup() -{ - if (!mLocation) - return NS_ERROR_NOT_IMPLEMENTED; - - // Not all versions of qt5positioning set default prefered method - // thus this workaround initializing QGeoPositionSource explicitly - SetHighAccuracy(false); - mLocation->startUpdates(); - - return NS_OK; -} - -NS_IMETHODIMP -QTMLocationProvider::Watch(nsIGeolocationUpdate* aCallback) -{ - mCallback = aCallback; - - return NS_OK; -} - -NS_IMETHODIMP -QTMLocationProvider::Shutdown() -{ - if (!mLocation) - return NS_ERROR_NOT_IMPLEMENTED; - - mLocation->stopUpdates(); - mCallback = nullptr; - - return NS_OK; -} - -NS_IMETHODIMP -QTMLocationProvider::SetHighAccuracy(bool aHigh) -{ - if (!mLocation) - return NS_ERROR_NOT_IMPLEMENTED; - - mLocation->setPreferredPositioningMethods(aHigh ? - QGeoPositionInfoSource::SatellitePositioningMethods : - QGeoPositionInfoSource::AllPositioningMethods); - return NS_OK; -} diff --git a/dom/system/qt/QTMLocationProvider.h b/dom/system/qt/QTMLocationProvider.h deleted file mode 100644 index 07b34c846119..000000000000 --- a/dom/system/qt/QTMLocationProvider.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef QTMLocationProvider_h -#define QTMLocationProvider_h - -#include -#include "nsGeolocation.h" -#include "nsIGeolocationProvider.h" -#include "nsCOMPtr.h" - -class QTMLocationProvider : public QObject, - public nsIGeolocationProvider -{ - Q_OBJECT - -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIGEOLOCATIONPROVIDER - - QTMLocationProvider(); - -public Q_SLOTS: - // QGeoPositionInfoSource - void positionUpdated(const QGeoPositionInfo&); - -private: - ~QTMLocationProvider(); - - QGeoPositionInfoSource* mLocation; - nsCOMPtr mCallback; -}; - -#endif /* QTMLocationProvider_h */ diff --git a/dom/system/qt/QtHapticFeedback.cpp b/dom/system/qt/QtHapticFeedback.cpp deleted file mode 100644 index 91aa1592d317..000000000000 --- a/dom/system/qt/QtHapticFeedback.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include "QtHapticFeedback.h" - -NS_IMPL_ISUPPORTS(QtHapticFeedback, nsIHapticFeedback) - -NS_IMETHODIMP -QtHapticFeedback::PerformSimpleAction(int32_t aType) -{ - if (aType == ShortPress) - QFeedbackEffect::playThemeEffect(QFeedbackEffect::PressWeak); - if (aType == LongPress) - QFeedbackEffect::playThemeEffect(QFeedbackEffect::PressStrong); - - return NS_OK; -} diff --git a/dom/system/qt/QtHapticFeedback.h b/dom/system/qt/QtHapticFeedback.h deleted file mode 100644 index 64fff752695b..000000000000 --- a/dom/system/qt/QtHapticFeedback.h +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIHapticFeedback.h" - -class QtHapticFeedback : public nsIHapticFeedback -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIHAPTICFEEDBACK -protected: - virtual ~QtHapticFeedback() {} -}; diff --git a/dom/system/qt/moz.build b/dom/system/qt/moz.build deleted file mode 100644 index 6e418008b29a..000000000000 --- a/dom/system/qt/moz.build +++ /dev/null @@ -1,26 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -if CONFIG['MOZ_ENABLE_QT5GEOPOSITION']: - SOURCES += [ - '!moc_QTMLocationProvider.cpp', - 'QTMLocationProvider.cpp', - ] - - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] - - LOCAL_INCLUDES += [ - '/dom/geolocation', - ] - -if CONFIG['MOZ_ENABLE_QT5FEEDBACK']: - SOURCES += [ - 'QtHapticFeedback.cpp', - ] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' diff --git a/gfx/cairo/cairo/src/moz.build b/gfx/cairo/cairo/src/moz.build index 5b9df771dfb5..7836fe37c639 100644 --- a/gfx/cairo/cairo/src/moz.build +++ b/gfx/cairo/cairo/src/moz.build @@ -81,13 +81,6 @@ elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: SOURCES += [ 'cairo-ps-surface.c', ] -elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - EXPORTS.cairo += [ - 'cairo-qt.h', - ] - SOURCES += [ - 'cairo-qt-surface.cpp', - ] if CONFIG['MOZ_X11']: EXPORTS.cairo += [ @@ -249,10 +242,6 @@ if CONFIG['GNU_CC'] and CONFIG['OS_TARGET'] == 'Android' and CONFIG['MOZ_OPTIMIZ CFLAGS += ['-O2'] CXXFLAGS += ['-O2'] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - CFLAGS += CONFIG['MOZ_QT_CFLAGS'] - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] - if CONFIG['MOZ_X11']: CFLAGS += CONFIG['XCFLAGS'] diff --git a/gfx/src/moz.build b/gfx/src/moz.build index a7f60c1a9265..10a9f8d0526f 100644 --- a/gfx/src/moz.build +++ b/gfx/src/moz.build @@ -91,6 +91,3 @@ CXXFLAGS += CONFIG['TK_CFLAGS'] if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS'] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] diff --git a/image/decoders/icon/qt/gtkqticonsconverter.js b/image/decoders/icon/qt/gtkqticonsconverter.js deleted file mode 100644 index a9c7a70bbda3..000000000000 --- a/image/decoders/icon/qt/gtkqticonsconverter.js +++ /dev/null @@ -1,141 +0,0 @@ -/* vim:set ts=2 sw=2 sts=2 cin et: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); - - -function GtkQtIconsConverter() -{ }; -GtkQtIconsConverter.prototype = -{ - classID: Components.ID("{c0783c34-a831-40c6-8c03-98c9f74cca45}"), - QueryInterface: XPCOMUtils.generateQI( - [Components.interfaces.nsIGtkQtIconsConverter]), - convert: function(icon) { return this._gtk_qt_icons_table[icon]; }, - _gtk_qt_icons_table: - { - 'about': - 0, - 'add': - 0, - 'apply': - 44, // QStyle::SP_DialogApplyButton - 'cancel': - 39, // QStyle::SP_DialogCancelButton - 'clear': - 45, // QStyle::SP_DialogResetButton - 'color-picker': - 0, - 'copy': - 0, - 'close': - 43, // QStyle::SP_DialogCloseButton - 'cut': - 0, - 'delete': - 0, - 'dialog-error': - 0, - 'dialog-info': - 0, - 'dialog-question': - 12, // QStyle::SP_MessageBoxQuestion - 'dialog-warning': - 10, // QStyle::SP_MessageBoxWarning - 'directory': - 37, // QStyle::SP_DirIcon - 'file': - 24, // QStyle::SP_FileIcon - 'find': - 0, - 'go-back-ltr': - 53, // QStyle::SP_ArrowBack - 'go-back-rtl': - 53, // QStyle::SP_ArrowBack - 'go-back': - 53, // QStyle::SP_ArrowBack - 'go-forward-ltr': - 54, // QStyle::SP_ArrowForward - 'go-forward-rtl': - 54, // QStyle::SP_ArrowForward - 'go-forward': - 54, // QStyle::SP_ArrowForward - 'go-up': - 49, // QStyle::SP_ArrowUp - 'goto-first': - 0, - 'goto-last': - 0, - 'help': - 7, // QStyle::SP_TitleBarContextHelpButton - 'home': - 55, // QStyle::SP_DirHomeIcon - 'info': - 9, // QStyle::SP_MessageBoxInformation - 'jump-to': - 0, - 'media-pause': - 0, - 'media-play': - 0, - 'network': - 20, // QStyle::SP_DriveNetIcon - 'no': - 48, // QStyle::SP_DialogNoButton - 'ok': - 38, // QStyle::SP_DialogOkButton - 'open': - 21, // QStyle::SP_DirOpenIcon - 'orientation-landscape': - 0, - 'orientation-portrait': - 0, - 'paste': - 0, - 'preferences': - 34, // QStyle::SP_FileDialogContentsView - 'print-preview': - 0, - 'print': - 0, - 'properties': - 0, - 'quit': - 0, - 'redo': - 0, - 'refresh': - 58, // QStyle::SP_BrowserReload - 'remove': - 0, - 'revert-to-saved': - 0, - 'save-as': - 42, // QStyle::SP_DialogSaveButton - 'save': - 42, // QStyle::SP_DialogSaveButton - 'select-all': - 0, - 'select-font': - 0, - 'stop': - 59, // QStyle::SP_BrowserStop - 'undelete': - 0, - 'undo': - 0, - 'yes': - 47, // QStyle::SP_DialogYesButton - 'zoom-100': - 0, - 'zoom-in': - 0, - 'zoom-out': - 0 - }, -} -var components = [GtkQtIconsConverter]; -this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components); - diff --git a/image/decoders/icon/qt/gtkqticonsconverter.manifest b/image/decoders/icon/qt/gtkqticonsconverter.manifest deleted file mode 100644 index 4d6ede281431..000000000000 --- a/image/decoders/icon/qt/gtkqticonsconverter.manifest +++ /dev/null @@ -1,2 +0,0 @@ -component {c0783c34-a831-40c6-8c03-98c9f74cca45} gtkqticonsconverter.js -contract @mozilla.org/gtkqticonsconverter;1 {c0783c34-a831-40c6-8c03-98c9f74cca45} diff --git a/image/decoders/icon/qt/moz.build b/image/decoders/icon/qt/moz.build deleted file mode 100644 index 0cf20fdb6d40..000000000000 --- a/image/decoders/icon/qt/moz.build +++ /dev/null @@ -1,27 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -XPIDL_SOURCES += [ - 'nsGtkQtIconsConverter.idl', -] - -XPIDL_MODULE = 'gtkqticonsconverter' - -SOURCES += [ - 'nsIconChannel.cpp', -] - -EXTRA_COMPONENTS += [ - 'gtkqticonsconverter.manifest', -] - -EXTRA_PP_COMPONENTS += [ - 'gtkqticonsconverter.js', -] - -FINAL_LIBRARY = 'xul' - -CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] diff --git a/image/decoders/icon/qt/nsGtkQtIconsConverter.idl b/image/decoders/icon/qt/nsGtkQtIconsConverter.idl deleted file mode 100644 index 958ae3394f69..000000000000 --- a/image/decoders/icon/qt/nsGtkQtIconsConverter.idl +++ /dev/null @@ -1,12 +0,0 @@ -/* vim:set ts=2 sw=2 sts=2 cin et: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -[scriptable, uuid(c0783c34-a831-40c6-8c03-98c9f74cca45)] -interface nsIGtkQtIconsConverter : nsISupports -{ - long convert(in string icon); -}; diff --git a/image/decoders/icon/qt/nsIconChannel.cpp b/image/decoders/icon/qt/nsIconChannel.cpp deleted file mode 100644 index d3a0aab1ae8d..000000000000 --- a/image/decoders/icon/qt/nsIconChannel.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* vim:set ts=2 sw=2 sts=2 cin et: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include - -#include -#include - -#include "mozilla/EndianUtils.h" - -#include "nsMimeTypes.h" -#include "nsIMIMEService.h" - -#include "nsIStringBundle.h" - -#include "nsNetUtil.h" -#include "nsNullPrincipal.h" -#include "nsIURL.h" - -#include "nsIconChannel.h" -#include "nsGtkQtIconsConverter.h" - -NS_IMPL_ISUPPORTS(nsIconChannel, - nsIRequest, - nsIChannel) - -static nsresult -moz_qicon_to_channel(QImage* image, nsIURI* aURI, - nsIChannel** aChannel) -{ - NS_ENSURE_ARG_POINTER(image); - - int width = image->width(); - int height = image->height(); - - NS_ENSURE_TRUE(height < 256 && width < 256 && height > 0 && width > 0, - NS_ERROR_UNEXPECTED); - - const int n_channels = 4; - long int buf_size = 2 + n_channels * height * width; - uint8_t* const buf = (uint8_t*)moz_xmalloc(buf_size); - NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY); - uint8_t* out = buf; - - *(out++) = width; - *(out++) = height; - - const uchar* const pixels = image->bits(); - int rowextra = image->bytesPerLine() - width * n_channels; - - // encode the RGB data and the A data - const uchar* in = pixels; - for (int y = 0; y < height; ++y, in += rowextra) { - for (int x = 0; x < width; ++x) { - uint8_t r = *(in++); - uint8_t g = *(in++); - uint8_t b = *(in++); - uint8_t a = *(in++); -#define DO_PREMULTIPLY(c_) uint8_t(uint16_t(c_) * uint16_t(a) / uint16_t(255)) -#if MOZ_LITTLE_ENDIAN - *(out++) = DO_PREMULTIPLY(b); - *(out++) = DO_PREMULTIPLY(g); - *(out++) = DO_PREMULTIPLY(r); - *(out++) = a; -#else - *(out++) = a; - *(out++) = DO_PREMULTIPLY(r); - *(out++) = DO_PREMULTIPLY(g); - *(out++) = DO_PREMULTIPLY(b); -#endif -#undef DO_PREMULTIPLY - } - } - - NS_ASSERTION(out == buf + buf_size, "size miscalculation"); - - nsresult rv; - nsCOMPtr stream = - do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = stream->AdoptData((char*)buf, buf_size); - NS_ENSURE_SUCCESS(rv, rv); - - // nsIconProtocolHandler::NewChannel2 will provide the correct loadInfo for - // this iconChannel. Use the most restrictive security settings for the - // temporary loadInfo to make sure the channel can not be openend. - nsCOMPtr nullPrincipal = nsNullPrincipal::Create(); - return NS_NewInputStreamChannel(aChannel, - aURI, - stream, - nullPrincipal, - nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED, - nsIContentPolicy::TYPE_INTERNAL_IMAGE, - NS_LITERAL_CSTRING(IMAGE_ICON_MS)); -} - -nsresult -nsIconChannel::Init(nsIURI* aURI) -{ - - nsCOMPtr iconURI = do_QueryInterface(aURI); - NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI"); - - nsAutoCString stockIcon; - iconURI->GetStockIcon(stockIcon); - - nsAutoCString iconSizeString; - iconURI->GetIconSize(iconSizeString); - - uint32_t desiredImageSize; - iconURI->GetImageSize(&desiredImageSize); - - nsAutoCString iconStateString; - iconURI->GetIconState(iconStateString); - bool disabled = iconStateString.EqualsLiteral("disabled"); - - // This is a workaround for - // https://bugzilla.mozilla.org/show_bug.cgi?id=662299 - // Try to find corresponding freedesktop icon and fallback to empty QIcon - // if failed. - QIcon icon = QIcon::fromTheme(QString(stockIcon.get()).replace("gtk-", - "edit-")); - QPixmap pixmap = icon.pixmap(desiredImageSize, desiredImageSize, - disabled ? QIcon::Disabled : QIcon::Normal); - - QImage image = pixmap.toImage(); - - return moz_qicon_to_channel(&image, iconURI, - getter_AddRefs(mRealChannel)); -} diff --git a/image/decoders/icon/qt/nsIconChannel.h b/image/decoders/icon/qt/nsIconChannel.h deleted file mode 100644 index 059891a71fae..000000000000 --- a/image/decoders/icon/qt/nsIconChannel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* vim:set ts=2 sw=2 sts=2 cin et: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_image_encoders_icon_qt_nsIconChannel_h -#define mozilla_image_encoders_icon_qt_nsIconChannel_h - -#include "mozilla/Attributes.h" - -#include "nsIChannel.h" -#include "nsIStreamListener.h" -#include "nsIURI.h" -#include "nsIIconURI.h" -#include "nsCOMPtr.h" - -/// This class is the gnome implementation of nsIconChannel. It basically asks -/// qt for an icon, and creates a new channel for -/// that file to which all calls will be proxied. -class nsIconChannel final : public nsIChannel { - public: - NS_DECL_ISUPPORTS - NS_FORWARD_NSIREQUEST(mRealChannel->) - NS_FORWARD_NSICHANNEL(mRealChannel->) - - nsIconChannel() { }; - - /// Called by nsIconProtocolHandler after it creates this channel. - /// Must be called before calling any other function on this object. - /// If this method fails, no other function must be called on this object. - nsresult Init(nsIURI* aURI); - private: - ~nsIconChannel() { }; - - /// The channel to the temp icon file (e.g. to /tmp/2qy9wjqw.html). - /// Will always be non-null after a successful Init. - nsCOMPtr mRealChannel; -}; - -#endif // mozilla_image_encoders_icon_qt_nsIconChannel_h diff --git a/image/decoders/moz.build b/image/decoders/moz.build index 356ee43b25d5..e28f0bed9795 100644 --- a/image/decoders/moz.build +++ b/image/decoders/moz.build @@ -10,8 +10,6 @@ toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] # fix that another time. if 'gtk' in toolkit: DIRS += ['icon/gtk', 'icon'] -elif toolkit == 'qt': - DIRS += ['icon/qt', 'icon'] if CONFIG['OS_ARCH'] == 'WINNT': DIRS += ['icon/win', 'icon'] diff --git a/intl/locale/moz.build b/intl/locale/moz.build index 70b161d9763c..4b1d4747e640 100644 --- a/intl/locale/moz.build +++ b/intl/locale/moz.build @@ -66,6 +66,3 @@ GENERATED_FILES += [ langgroups = GENERATED_FILES['langGroups.properties.h'] langgroups.script = 'props2arrays.py' langgroups.inputs = ['langGroups.properties'] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] diff --git a/intl/unicharutil/tables/moz.build b/intl/unicharutil/tables/moz.build index ded6ee75822a..65d0bf4411dc 100644 --- a/intl/unicharutil/tables/moz.build +++ b/intl/unicharutil/tables/moz.build @@ -10,7 +10,3 @@ RESOURCE_FILES.entityTables = [ 'html40Symbols.properties', 'mathml20.properties', ] - -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - CFLAGS += CONFIG['MOZ_QT_CFLAGS'] - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build index f5514c337013..1d27e5e69d85 100644 --- a/ipc/chromium/moz.build +++ b/ipc/chromium/moz.build @@ -139,11 +139,6 @@ if os_bsd or os_linux: SOURCES += [ 'src/base/message_pump_glib.cc', ] - if CONFIG['MOZ_ENABLE_QT']: - SOURCES += [ - '!moc_message_pump_qt.cc', - 'src/base/message_pump_qt.cc', - ] ost = CONFIG['OS_TEST'] if '86' not in ost and 'arm' not in ost and 'aarch64' != ost and 'mips' not in ost: diff --git a/layout/generic/moz.build b/layout/generic/moz.build index eb1e759ff4e7..689941a0b146 100644 --- a/layout/generic/moz.build +++ b/layout/generic/moz.build @@ -213,8 +213,5 @@ CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: CXXFLAGS += CONFIG['TK_CFLAGS'] -if CONFIG['MOZ_ENABLE_QT']: - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] - if CONFIG['GNU_CXX']: CXXFLAGS += ['-Wno-error=shadow'] diff --git a/netwerk/base/moz.build b/netwerk/base/moz.build index 7fd247383a18..eb90c2349dbe 100644 --- a/netwerk/base/moz.build +++ b/netwerk/base/moz.build @@ -303,10 +303,6 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': 'nsNetworkInfoService.cpp', ] -if CONFIG['MOZ_ENABLE_QTNETWORK']: - SOURCES += [ - ] - EXTRA_COMPONENTS += [ 'PACGenerator.js', 'PACGenerator.manifest' @@ -332,13 +328,5 @@ if 'rtsp' in CONFIG['NECKO_PROTOCOLS']: '/netwerk/protocol/rtsp/rtsp', ] -if CONFIG['MOZ_ENABLE_QTNETWORK']: - LOCAL_INCLUDES += [ - '/netwerk/system/qt', - ] - -if CONFIG['MOZ_ENABLE_QTNETWORK']: - CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] - if CONFIG['GNU_CXX']: CXXFLAGS += ['-Wno-error=shadow'] diff --git a/netwerk/build/moz.build b/netwerk/build/moz.build index a3ba3c7ceacf..04d94f773b31 100644 --- a/netwerk/build/moz.build +++ b/netwerk/build/moz.build @@ -43,11 +43,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': '/netwerk/system/mac', ] -if CONFIG['MOZ_ENABLE_QTNETWORK']: - LOCAL_INCLUDES += [ - '/netwerk/system/qt', - ] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': LOCAL_INCLUDES += [ '/netwerk/system/android', diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp index 4b50d155c558..22cfcf98fdc1 100644 --- a/netwerk/build/nsNetModule.cpp +++ b/netwerk/build/nsNetModule.cpp @@ -415,9 +415,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init) #elif defined(MOZ_WIDGET_COCOA) #include "nsNetworkLinkService.h" NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init) -#elif defined(MOZ_ENABLE_QTNETWORK) -#include "nsQtNetworkLinkService.h" -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsQtNetworkLinkService, Init) #elif defined(MOZ_WIDGET_ANDROID) #include "nsAndroidNetworkLinkService.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidNetworkLinkService) @@ -856,8 +853,6 @@ NS_DEFINE_NAMED_CID(NS_RTSPPROTOCOLHANDLER_CID); NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); #elif defined(MOZ_WIDGET_COCOA) NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); -#elif defined(MOZ_ENABLE_QTNETWORK) -NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); #elif defined(MOZ_WIDGET_ANDROID) NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID); #elif defined(XP_LINUX) @@ -1011,8 +1006,6 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = { { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNotifyAddrListenerConstructor }, #elif defined(MOZ_WIDGET_COCOA) { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsNetworkLinkServiceConstructor }, -#elif defined(MOZ_ENABLE_QTNETWORK) - { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsQtNetworkLinkServiceConstructor }, #elif defined(MOZ_WIDGET_ANDROID) { &kNS_NETWORK_LINK_SERVICE_CID, false, nullptr, nsAndroidNetworkLinkServiceConstructor }, #elif defined(XP_LINUX) @@ -1171,8 +1164,6 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = { { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, #elif defined(MOZ_WIDGET_COCOA) { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, -#elif defined(MOZ_ENABLE_QTNETWORK) - { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, #elif defined(MOZ_WIDGET_ANDROID) { NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID }, #elif defined(XP_LINUX) diff --git a/netwerk/system/moz.build b/netwerk/system/moz.build index 18e923b39395..03f0362fa247 100644 --- a/netwerk/system/moz.build +++ b/netwerk/system/moz.build @@ -10,9 +10,6 @@ if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': DIRS += ['mac'] -if CONFIG['MOZ_ENABLE_QTNETWORK']: - DIRS += ['qt'] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': DIRS += ['android'] diff --git a/netwerk/system/qt/moz.build b/netwerk/system/qt/moz.build deleted file mode 100644 index cc8b5ef5fbc7..000000000000 --- a/netwerk/system/qt/moz.build +++ /dev/null @@ -1,18 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -SOURCES += [ - '!moc_nsQtNetworkManager.cpp', - 'nsQtNetworkLinkService.cpp', - 'nsQtNetworkManager.cpp', -] - -FINAL_LIBRARY = 'xul' -LOCAL_INCLUDES += [ - '/netwerk/base', -] - -CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] diff --git a/netwerk/system/qt/nsQtNetworkLinkService.cpp b/netwerk/system/qt/nsQtNetworkLinkService.cpp deleted file mode 100644 index f08aabbd8ed6..000000000000 --- a/netwerk/system/qt/nsQtNetworkLinkService.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsQtNetworkManager.h" -#include "nsQtNetworkLinkService.h" -#include "nsCOMPtr.h" -#include "nsIObserverService.h" -#include "nsServiceManagerUtils.h" -#include "nsString.h" -#include "mozilla/Services.h" -#include "nsCRT.h" - -NS_IMPL_ISUPPORTS(nsQtNetworkLinkService, - nsINetworkLinkService, - nsIObserver) - -nsQtNetworkLinkService::nsQtNetworkLinkService() -{ -} - -nsQtNetworkLinkService::~nsQtNetworkLinkService() -{ -} - -NS_IMETHODIMP -nsQtNetworkLinkService::GetIsLinkUp(bool* aIsUp) -{ - *aIsUp = nsQtNetworkManager::get()->isOnline(); - return NS_OK; -} - -NS_IMETHODIMP -nsQtNetworkLinkService::GetLinkStatusKnown(bool* aIsKnown) -{ - *aIsKnown = nsQtNetworkManager::get()->isOnline(); - return NS_OK; -} - -NS_IMETHODIMP -nsQtNetworkLinkService::GetLinkType(uint32_t *aLinkType) -{ - NS_ENSURE_ARG_POINTER(aLinkType); - - // XXX This function has not yet been implemented for this platform - *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; - return NS_OK; -} - -NS_IMETHODIMP -nsQtNetworkLinkService::Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aData) -{ - if (!strcmp(aTopic, "xpcom-shutdown")) { - Shutdown(); - nsQtNetworkManager::get()->destroy(); - } - - if (!strcmp(aTopic, "browser-lastwindow-close-granted")) { - Shutdown(); - } - - return NS_OK; -} - -nsresult -nsQtNetworkLinkService::Init(void) -{ - nsCOMPtr observerService = - mozilla::services::GetObserverService(); - if (!observerService) { - return NS_ERROR_FAILURE; - } - - nsQtNetworkManager::create(); - nsresult rv; - - rv = observerService->AddObserver(this, "xpcom-shutdown", false); - if (NS_FAILED(rv)) { - return NS_ERROR_FAILURE; - } - - rv = observerService->AddObserver(this, "browser-lastwindow-close-granted", false); - if (NS_FAILED(rv)) { - return NS_ERROR_FAILURE; - } - - - return NS_OK; -} - -nsresult -nsQtNetworkLinkService::Shutdown() -{ - nsQtNetworkManager::get()->closeSession(); - return NS_OK; -} diff --git a/netwerk/system/qt/nsQtNetworkLinkService.h b/netwerk/system/qt/nsQtNetworkLinkService.h deleted file mode 100644 index 681d49e39bfb..000000000000 --- a/netwerk/system/qt/nsQtNetworkLinkService.h +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef NSQTNETWORKLINKSERVICE_H_ -#define NSQTNETWORKLINKSERVICE_H_ - -#include "nsINetworkLinkService.h" -#include "nsIObserver.h" - -class nsQtNetworkLinkService: public nsINetworkLinkService, - public nsIObserver -{ - -public: - NS_DECL_ISUPPORTS - NS_DECL_NSINETWORKLINKSERVICE - NS_DECL_NSIOBSERVER - - nsQtNetworkLinkService(); - - nsresult Init(); - nsresult Shutdown(); - -private: - virtual ~nsQtNetworkLinkService(); -}; - -#endif /* NSQTNETWORKLINKSERVICE_H_ */ diff --git a/netwerk/system/qt/nsQtNetworkManager.cpp b/netwerk/system/qt/nsQtNetworkManager.cpp deleted file mode 100644 index c4be6faa7326..000000000000 --- a/netwerk/system/qt/nsQtNetworkManager.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsQtNetworkManager.h" - -#include "nsCOMPtr.h" -#include "nsThreadUtils.h" -#include "nsINetworkLinkService.h" -#include "nsIOService.h" -#include "nsIObserverService.h" -#include "nsIOService.h" - -#include -#include -#include - -nsQtNetworkManager* nsQtNetworkManager::gQtNetworkManager = nullptr; - -void nsQtNetworkManager::create() -{ - if (!gQtNetworkManager) { - gQtNetworkManager = new nsQtNetworkManager(); - connect(gQtNetworkManager, SIGNAL(openConnectionSignal()), - gQtNetworkManager, SLOT(openSession()), - Qt::BlockingQueuedConnection); - connect(&gQtNetworkManager->networkConfigurationManager, - SIGNAL(onlineStateChanged(bool)), gQtNetworkManager, - SLOT(onlineStateChanged(bool))); - } -} - -void nsQtNetworkManager::destroy() -{ - delete gQtNetworkManager; - gQtNetworkManager = nullptr; -} - -nsQtNetworkManager::nsQtNetworkManager(QObject* parent) - : QObject(parent), networkSession(0) -{ - mOnline = networkConfigurationManager.isOnline(); - NS_ASSERTION(NS_IsMainThread(), "nsQtNetworkManager can only initiated in Main Thread"); -} - -nsQtNetworkManager::~nsQtNetworkManager() -{ - closeSession(); - networkSession->deleteLater(); -} - -bool -nsQtNetworkManager::isOnline() -{ - static bool sForceOnlineUSB = getenv("MOZ_MEEGO_NET_ONLINE") != 0; - return sForceOnlineUSB || mOnline; -} - -void -nsQtNetworkManager::onlineStateChanged(bool online) -{ - mOnline = online; -} - -/* - This function is called from different threads, we need to make sure that - the attempt to create a network connection is done in the mainthread - - In case this function is called by another thread than the mainthread - we emit a signal which is connected through "BlockingQueue"-Connection Type. - - This cause that the current thread is blocked and waiting for the result. - - Of course, in case this gets called from the mainthread we must not emit the signal, - but call the slot directly. -*/ - -bool -nsQtNetworkManager::openConnection(const QString& host) -{ - // we are already online -> return true. - if (isOnline()) { - return true; - } - - if (NS_IsMainThread()) { - openSession(); - } else { - // jump to mainthread and do the work there - Q_EMIT openConnectionSignal(); - } - - // if its claiming its online -> send one resolve request ahead. - // this is important because on mobile the first request can take up to 10 seconds - // sending here one will help to avoid trouble and timeouts later - if (isOnline()) { - QHostInfo::fromName(host); - } - - return isOnline(); -} - -void -nsQtNetworkManager::openSession() -{ - if (mBlockTimer.isActive()) { - // if openSession is called within 200 ms again, we forget this attempt since - // its mostlike an automatic connection attempt which was not successful or canceled 200ms ago. - // we reset the timer and start it again. - - // As example: Go in firefox mobile into AwesomeView, see that the icons are not always cached and - // get loaded on the fly. Not having the 200 ms rule here would mean that instantly - // after the user dismissed the one connection dialog once another - // would get opened. The user will never be able to close / leave the view until each such attempt is gone through. - - // Basically 200 ms are working fine, its huge enough for automatic attempts to get covered and small enough to - // still be able to react on direct user request. - - mBlockTimer.stop(); - mBlockTimer.setSingleShot(true); - mBlockTimer.start(200); - return; - } - - if (isOnline()) { - return; - } - - // this only means we did not shutdown before... - // renew Session every time - // fix/workaround for prestart bug - if (networkSession) { - networkSession->close(); - networkSession->deleteLater(); - } - - // renew always to react on changed Configurations - networkConfigurationManager.updateConfigurations(); - // go always with default configuration - networkConfiguration = networkConfigurationManager.defaultConfiguration(); - networkSession = new QNetworkSession(networkConfiguration); - - networkSession->open(); - QTime current; - current.start(); - networkSession->waitForOpened(-1); - - if (current.elapsed() < 1000) { - NS_WARNING("Connection Creation was to fast, something is not right."); - } - - mBlockTimer.setSingleShot(true); - mBlockTimer.start(200); -} - -void -nsQtNetworkManager::closeSession() -{ - if (networkSession) { - networkSession->close(); - } -} diff --git a/netwerk/system/qt/nsQtNetworkManager.h b/netwerk/system/qt/nsQtNetworkManager.h deleted file mode 100644 index 314e3fc02873..000000000000 --- a/netwerk/system/qt/nsQtNetworkManager.h +++ /dev/null @@ -1,56 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef NSQTNETWORKMANAGER_H_ -#define NSQTNETWORKMANAGER_H_ - -#include -#include -#include -#include -#include -#include "nscore.h" - -class nsQtNetworkManager; - - - -class nsQtNetworkManager : public QObject -{ - Q_OBJECT - public: - static void create(); - static void destroy(); - virtual ~nsQtNetworkManager(); - - static nsQtNetworkManager* get() { return gQtNetworkManager; } - - static bool IsConnected(); - static bool GetLinkStatusKnown(); - static void enableInstance(); - bool openConnection(const QString&); - bool isOnline(); - Q_SIGNALS: - void openConnectionSignal(); - - public Q_SLOTS: - void closeSession(); - void onlineStateChanged(bool); - - private Q_SLOTS: - void openSession(); - - private: - explicit nsQtNetworkManager(QObject* parent = 0); - - static nsQtNetworkManager* gQtNetworkManager; - QNetworkSession* networkSession; - QNetworkConfiguration networkConfiguration; - QNetworkConfigurationManager networkConfigurationManager; - QTimer mBlockTimer; - bool mOnline; -}; - -#endif /* NSQTNETWORKMANAGER_H_ */ - diff --git a/old-configure.in b/old-configure.in index 3661b13e60f7..e2b42f08c20a 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2865,12 +2865,6 @@ dnl ======================================================== case "$MOZ_WIDGET_TOOLKIT" in -qt) - MOZ_ENABLE_QT=1 - - AC_DEFINE(QT_NO_KEYWORDS) - ;; - cocoa) LDFLAGS="$LDFLAGS -framework Cocoa -lobjc" # Use -Wl as a trick to avoid -framework and framework names from @@ -2985,174 +2979,9 @@ if test "$NS_PRINTING"; then AC_DEFINE(NS_PRINT_PREVIEW) fi -dnl ======================================================== -dnl = QT support -dnl ======================================================== -if test "$MOZ_ENABLE_QT" -then - MOZ_ARG_WITH_STRING(qtdir, - [ --with-qtdir=\$dir Specify Qt directory ], - [ QTDIR=$withval]) - - if test -z "$QTDIR"; then - AC_CHECK_PROGS(HOST_QMAKE, $HOST_QMAKE qmake, "") - else - HOST_QMAKE="$QTDIR/bin/qmake" - fi - QT_VERSION=`$HOST_QMAKE -v | grep 'Using Qt version' | egrep -o '[[0-9]]+\.[[0-9]]+\.[[0-9]]+'` - - if test -z "$QTDIR"; then - case $QT_VERSION in - 5.*) - AC_MSG_RESULT("Using qt5: $QT_VERSION") - PKG_CHECK_MODULES(MOZ_QT, Qt5Gui Qt5Network Qt5Core Qt5Quick, , - [ - AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qtbase development packages, (On Ubuntu, you might try installing the packages qtbase5-dev libqt5opengl5-dev.)]) - ]) - QT5INCDIR=`pkg-config --variable=includedir Qt5Gui` - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QT5INCDIR/QtGui/$QT_VERSION/QtGui" - if test "$NS_PRINTING"; then - PKG_CHECK_MODULES(MOZ_QT_WIDGETS, Qt5PrintSupport, , - [ - AC_MSG_ERROR([$MOZ_QT_PKG_ERRORS Need qt5 printsupport development package]) - ]) - MOZ_QT_LIBS="$MOZ_QT_LIBS $MOZ_QT_WIDGETS_LIBS" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $MOZ_QT_WIDGETS_CFLAGS" - fi - ;; - *) - AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION]) - ;; - esac - - AC_CHECK_PROGS(HOST_MOC, $MOC moc, "") - AC_CHECK_PROGS(HOST_RCC, $RCC rcc, "") - else - MOZ_QT_CFLAGS="-DQT_SHARED" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include" - 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/QtXml" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtDeclarative" - case $QT_VERSION in - 5.*) - AC_MSG_RESULT("Using qt5: $QT_VERSION") - MOZ_QT_LIBS="$MOZ_QT_LIBS -L$QTDIR/lib/ -lQt5Gui -lQt5Network -lQt5Core -lQt5Xml" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtGui/$QT_VERSION/QtGui" - if test "$NS_PRINTING"; then - MOZ_QT_LIBS="$MOZ_QT_LIBS -lQt5Widgets -lQt5PrintSupport" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtPrintSupport" - fi - ;; - *) - AC_MSG_ERROR([* * * Unsupported Qt Version: $QT_VERSION]) - ;; - esac - - HOST_MOC="$QTDIR/bin/moc" - HOST_RCC="$QTDIR/bin/rcc" - 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 - if test -z "$HOST_RCC"; then - AC_MSG_ERROR([No acceptable rcc preprocessor found. Qt SDK is not installed or --with-qt is incorrect]) - fi - - MOC=$HOST_MOC - RCC=$HOST_RCC - - MOZ_ENABLE_QMSYSTEM2= - PKG_CHECK_MODULES(_QMSYSTEM2, qmsystem2, - MOZ_ENABLE_QMSYSTEM2=1, - MOZ_ENABLE_QMSYSTEM2=) - - if test "$MOZ_ENABLE_QMSYSTEM2"; then - MOZ_ENABLE_QMSYSTEM2=1 - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QMSYSTEM2_CFLAGS" - MOZ_QT_LIBS="$MOZ_QT_LIBS $_QMSYSTEM2_LIBS" - AC_DEFINE(MOZ_ENABLE_QMSYSTEM2) - fi - - MOZ_ENABLE_QTNETWORK= - PKG_CHECK_MODULES(_QTNETWORK, QtNetwork >= 4.7, - MOZ_ENABLE_QTNETWORK=1, - MOZ_ENABLE_QTNETWORK=) - - if test "$MOZ_ENABLE_QTNETWORK"; then - MOZ_ENABLE_QTNETWORK=1 - AC_DEFINE(MOZ_ENABLE_QTNETWORK) - fi - - MOZ_ENABLE_QTMOBILITY= - PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation, - MOZ_ENABLE_QTMOBILITY=1, - MOZ_ENABLE_QTMOBILITY=) - if test "$MOZ_ENABLE_QTMOBILITY"; then - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS" - MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS" - else - AC_CHECK_LIB(QtSensors, main, [ - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtMobility" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtSensors" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtFeedback" - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I$QTDIR/include/QtLocation" - MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation" - ]) - fi - - MOZ_ENABLE_QT5FEEDBACK= - PKG_CHECK_MODULES(_QT5FEEDBACK, Qt0Feedback, - MOZ_ENABLE_QT5FEEDBACK=1, - MOZ_ENABLE_QT5FEEDBACK=) - if test "$MOZ_ENABLE_QT5FEEDBACK"; then - MOZ_ENABLE_QT5FEEDBACK=1 - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5FEEDBACK_CFLAGS" - MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5FEEDBACK_LIBS" - AC_DEFINE(MOZ_ENABLE_QT5FEEDBACK) - AC_SUBST(MOZ_ENABLE_QT5FEEDBACK) - fi - - MOZ_ENABLE_QT5GEOPOSITION= - PKG_CHECK_MODULES(_QT5GEOPOSITION, Qt5Positioning, - MOZ_ENABLE_QT5GEOPOSITION=1, - MOZ_ENABLE_QT5GEOPOSITION=) - if test "$MOZ_ENABLE_QT5GEOPOSITION"; then - MOZ_ENABLE_QT5GEOPOSITION=1 - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QT5GEOPOSITION_CFLAGS" - MOZ_QT_LIBS="$MOZ_QT_LIBS $_QT5GEOPOSITION_LIBS" - AC_DEFINE(MOZ_ENABLE_QT5GEOPOSITION) - AC_SUBST(MOZ_ENABLE_QT5GEOPOSITION) - fi - - if test "$MOZ_ENABLE_CONTENTACTION"; then - MOZ_ENABLE_CONTENTACTION=1 - AC_DEFINE(MOZ_ENABLE_CONTENTACTION) - fi - - MOZ_ENABLE_CONTENTACTION= - PKG_CHECK_MODULES(LIBCONTENTACTION, contentaction-0.1, _LIB_FOUND=1, _LIB_FOUND=) - if test "$MOZ_ENABLE_CONTENTACTION"; then - MOZ_ENABLE_CONTENTACTION=1 - MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_CONTENTACTION_CFLAGS" - MOZ_QT_LIBS="$MOZ_QT_LIBS $_CONTENTACTION_LIBS" - AC_DEFINE(MOZ_ENABLE_CONTENTACTION) - AC_SUBST(MOZ_ENABLE_CONTENTACTION) - fi - TK_CFLAGS=$MOZ_QT_CFLAGS - TK_LIBS=$MOZ_QT_LIBS -fi - AC_SUBST_LIST(TK_CFLAGS) AC_SUBST_LIST(TK_LIBS) -AC_SUBST(MOZ_ENABLE_QT) -AC_SUBST(MOZ_ENABLE_QTNETWORK) -AC_SUBST(MOZ_ENABLE_QMSYSTEM2) -AC_SUBST_LIST(MOZ_QT_CFLAGS) -AC_SUBST_LIST(MOZ_QT_LIBS) - AC_SUBST(MOC) AC_SUBST(RCC) @@ -3229,7 +3058,7 @@ MOZ_ANDROID_INSTALL_TRACKING dnl ======================================================== dnl = Pango dnl ======================================================== -if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT" +if test "$MOZ_ENABLE_GTK" then PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION) @@ -3314,7 +3143,7 @@ dnl ======================================================== dnl = libproxy support dnl ======================================================== -if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT" +if test "$MOZ_ENABLE_GTK" then MOZ_ENABLE_LIBPROXY= @@ -3367,7 +3196,7 @@ dnl ======================================================== dnl = dbus support dnl ======================================================== -if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT" +if test "$MOZ_ENABLE_GTK" then MOZ_ENABLE_DBUS=1 @@ -3389,7 +3218,7 @@ dnl ======================================================== dnl = speech-dispatcher support dnl ======================================================== -if test "$MOZ_ENABLE_GTK" -o "$MOZ_ENABLE_QT" +if test "$MOZ_ENABLE_GTK" then MOZ_SYNTH_SPEECHD=1 diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 15b7607185d2..758f16e35f7e 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -127,7 +127,7 @@ if CONFIG['MOZ_JPROF']: 'jprof', ] -if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt' or \ +if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT'] or \ CONFIG['MOZ_TREE_FREETYPE']: USE_LIBS += [ 'freetype', @@ -302,13 +302,6 @@ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: 'gthread-2.0', ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': - OS_LIBS += CONFIG['XLDFLAGS'] - OS_LIBS += CONFIG['XLIBS'] - OS_LIBS += CONFIG['XT_LIBS'] - OS_LIBS += CONFIG['MOZ_QT_LIBS'] - OS_LIBS += CONFIG['MOZ_PANGO_LIBS'] - if CONFIG['MOZ_ENABLE_STARTUP_NOTIFICATION']: OS_LIBS += CONFIG['MOZ_STARTUP_NOTIFICATION_LIBS'] @@ -364,9 +357,6 @@ if CONFIG['OS_ARCH'] == 'WINNT': 'oleacc', ] -if CONFIG['MOZ_ENABLE_QT']: - OS_LIBS += CONFIG['XEXT_LIBS'] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': OS_LIBS += [ 'usp10', diff --git a/toolkit/moz.configure b/toolkit/moz.configure index 5c2d7f8ff349..a126526ce0ab 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -98,7 +98,7 @@ set_config('L10NBASEDIR', l10n_base) # reason. option('--enable-default-toolkit', nargs=1, choices=('cairo-windows', 'cairo-gtk2', 'cairo-gtk2-x11', 'cairo-gtk3', - 'cairo-qt', 'cairo-cocoa', 'cairo-uikit', 'cairo-android', + 'cairo-cocoa', 'cairo-uikit', 'cairo-android', 'cairo-gonk'), help='Select default toolkit') @@ -121,8 +121,7 @@ def toolkit(value, target): else: platform_choices = ('cairo-android',) else: - platform_choices = ('cairo-gtk3', 'cairo-gtk2', 'cairo-gtk2-x11', - 'cairo-qt') + platform_choices = ('cairo-gtk3', 'cairo-gtk2', 'cairo-gtk2-x11') if value: if value[0] not in platform_choices: @@ -165,10 +164,10 @@ option('--without-x', env='WITHOUT_X', help='Disable X11 support') @depends('--without-x', toolkit) def x11(value, toolkit): - if not value and toolkit != 'qt': - die('--without-x is only valid with --enable-default-toolkit=qt') + if not value: + die('--without-x is not supported') - x11_toolkits = ('gtk2', 'gtk3', 'qt') + x11_toolkits = ('gtk2', 'gtk3') if value and value.origin != 'default' and toolkit not in x11_toolkits: die('--with-x is only valid with --enable-default-toolkit={%s}', ','.join(x11_toolkits)) @@ -219,7 +218,7 @@ set_define(gl_provider_define, True) # ============================================================== @depends(toolkit) def pdf_printing(toolkit): - if toolkit in ('windows', 'gtk2', 'gtk3', 'qt', 'android', 'gonk'): + if toolkit in ('windows', 'gtk2', 'gtk3', 'android', 'gonk'): return True @depends(pdf_printing) @@ -256,7 +255,7 @@ option(env='USE_FC_FREETYPE', @depends('USE_FC_FREETYPE', toolkit) def fc_freetype(value, toolkit): - if value or (toolkit in ('gtk2', 'gtk3', 'qt') and + if value or (toolkit in ('gtk2', 'gtk3') and value.origin == 'default'): return True diff --git a/widget/moz.build b/widget/moz.build index 570606eb74dc..0ac71830998e 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -6,9 +6,9 @@ toolkit = CONFIG['MOZ_WIDGET_TOOLKIT'] -if toolkit in ('cocoa', 'qt', 'android', 'gonk', 'uikit'): +if toolkit in ('cocoa', 'android', 'gonk', 'uikit'): DIRS += [toolkit] -if toolkit in ('qt', 'android', 'gonk', 'gtk2', 'gtk3'): +if toolkit in ('android', 'gonk', 'gtk2', 'gtk3'): EXPORTS += ['nsIPrintDialogService.h'] if toolkit == 'windows': @@ -211,13 +211,13 @@ if toolkit in ('cocoa', 'windows'): 'nsBaseClipboard.cpp', ] -if toolkit in {'qt', 'gtk2', 'gtk3', 'cocoa', 'windows', +if toolkit in {'gtk2', 'gtk3', 'cocoa', 'windows', 'android', 'gonk', 'uikit'}: UNIFIED_SOURCES += [ 'nsBaseFilePicker.cpp', ] -if toolkit in ('qt', 'gtk2', 'gtk3', 'windows', 'cocoa'): +if toolkit in ('gtk2', 'gtk3', 'windows', 'cocoa'): UNIFIED_SOURCES += [ 'nsNativeTheme.cpp', ] diff --git a/widget/qt/GfxInfo.cpp b/widget/qt/GfxInfo.cpp deleted file mode 100644 index 1a506831faa4..000000000000 --- a/widget/qt/GfxInfo.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "GfxInfo.h" - -using namespace mozilla::widget; - -/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization - * has occurred because they depend on it for information. (See bug 591561) */ -nsresult -GfxInfo::GetD2DEnabled(bool *aEnabled) -{ - return NS_ERROR_FAILURE; -} - -nsresult -GfxInfo::GetDWriteEnabled(bool *aEnabled) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription) -{ - aAdapterDescription.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM) -{ - aAdapterRAM.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver) -{ - aAdapterDriver.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion) -{ - aAdapterDriverVersion.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate) -{ - aAdapterDriverDate.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID) -{ - aAdapterVendorID.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID) -{ - aAdapterDeviceID.Truncate(); - return NS_OK; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterSubsysID(nsAString & aAdapterSubsysID) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetAdapterSubsysID2(nsAString & aAdapterSubsysID) -{ - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) -{ - return NS_ERROR_FAILURE; -} - -const nsTArray& -GfxInfo::GetGfxDriverInfo() -{ - return *mDriverInfo; -} - -uint32_t GfxInfo::OperatingSystemVersion() -{ - return 0; -} - -nsresult -GfxInfo::GetFeatureStatusImpl(int32_t /*aFeature*/, - int32_t *aStatus, - nsAString & /*aSuggestedDriverVersion*/, - const nsTArray& /*aDriverInfo*/, - OperatingSystem* /*aOS*/ /* = nullptr */) -{ - NS_ENSURE_ARG_POINTER(aStatus); - *aStatus = nsIGfxInfo::FEATURE_STATUS_OK; - - return NS_OK; -} - -#ifdef DEBUG - -// Implement nsIGfxInfoDebug - -NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString &) -{ - return NS_OK; -} - -NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString &) -{ - return NS_OK; -} - -NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString &) -{ - return NS_OK; -} - -NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t) -{ - return NS_OK; -} - -#endif diff --git a/widget/qt/GfxInfo.h b/widget/qt/GfxInfo.h deleted file mode 100644 index b4311173f9cd..000000000000 --- a/widget/qt/GfxInfo.h +++ /dev/null @@ -1,68 +0,0 @@ -/* vim: se cin sw=2 ts=2 et : */ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __mozilla_widget_GfxInfo_h__ -#define __mozilla_widget_GfxInfo_h__ - -#include "GfxInfoBase.h" -#include "GfxDriverInfo.h" - -#include "nsString.h" - -namespace mozilla { -namespace widget { - -class GfxInfo : public GfxInfoBase -{ -public: - // We only declare the subset of nsIGfxInfo that we actually implement. The - // rest is brought forward from GfxInfoBase. - NS_IMETHOD GetD2DEnabled(bool *aD2DEnabled); - NS_IMETHOD GetDWriteEnabled(bool *aDWriteEnabled); - NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion); - NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams); - NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription); - NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver); - NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID); - NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID); - NS_IMETHOD GetAdapterSubsysID(nsAString & aAdapterSubsysID); - NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM); - NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion); - NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate); - NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription); - NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver); - NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID); - NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID); - NS_IMETHOD GetAdapterSubsysID2(nsAString & aAdapterSubsysID); - NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM); - NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion); - NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate); - NS_IMETHOD GetIsGPU2Active(bool *aIsGPU2Active); - using GfxInfoBase::GetFeatureStatus; - using GfxInfoBase::GetFeatureSuggestedDriverVersion; - using GfxInfoBase::GetWebGLParameter; - - virtual uint32_t OperatingSystemVersion() override; - -#ifdef DEBUG - NS_DECL_NSIGFXINFODEBUG -#endif - -protected: - - virtual nsresult GetFeatureStatusImpl(int32_t aFeature, - int32_t *aStatus, - nsAString & aSuggestedDriverVersion, - const nsTArray& aDriverInfo, - OperatingSystem* aOS = nullptr); - virtual const nsTArray& GetGfxDriverInfo(); -}; - -} // namespace widget -} // namespace mozilla - -#endif /* __mozilla_widget_GfxInfo_h__ */ diff --git a/widget/qt/moz.build b/widget/qt/moz.build deleted file mode 100644 index 8003864d9559..000000000000 --- a/widget/qt/moz.build +++ /dev/null @@ -1,66 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -SOURCES += [ - '!moc_mozqwidget.cpp', - '!moc_nsAppShell.cpp', - 'mozqwidget.cpp', - 'nsAppShell.cpp', - 'nsBidiKeyboard.cpp', - 'nsClipboard.cpp', - 'nsIdleServiceQt.cpp', - 'nsLookAndFeel.cpp', - 'nsQtKeyUtils.cpp', - 'nsScreenManagerQt.cpp', - 'nsScreenQt.cpp', - 'nsWidgetFactory.cpp', - 'nsWindow.cpp', -] - - -if CONFIG['NS_PRINTING']: - SOURCES += [ - 'nsDeviceContextSpecQt.cpp', - 'nsPrintDialogQt.cpp', - 'nsPrintOptionsQt.cpp', - 'nsPrintSettingsQt.cpp', - ] - -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '/widget', -] - -if CONFIG['MOZ_X11']: - LOCAL_INCLUDES += [ - '../x11', - ] -else: - SOURCES += [ - 'GfxInfo.cpp', - ] - - -#DEFINES['DEBUG_WIDGETS'] = True - -if CONFIG['OS_ARCH'] == 'Linux': - DEFINES['_BSD_SOURCE'] = True - -if CONFIG['OS_ARCH'] == 'SunOS' and not CONFIG['GNU_CC']: - # When using Sun's WorkShop compiler, including - # /wherever/workshop-5.0/SC5.0/include/CC/std/time.h - # causes most of these compiles to fail with: - # line 29: Error: Multiple declaration for std::tm. - # So, this gets around the problem. - DEFINES['_TIME_H'] = 1 - -CXXFLAGS += CONFIG['MOZ_QT_CFLAGS'] -CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] -CFLAGS += CONFIG['MOZ_QT_CFLAGS'] -CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] diff --git a/widget/qt/mozqwidget.cpp b/widget/qt/mozqwidget.cpp deleted file mode 100644 index 944cc2c08d3d..000000000000 --- a/widget/qt/mozqwidget.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim: set ts=4 et sw=4 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include - -#include "mozqwidget.h" -#include "nsWindow.h" - -using namespace mozilla::widget; - -MozQWidget::MozQWidget(nsWindow* aReceiver, QWindow* aParent) - : QWindow(aParent) - , mReceiver(aReceiver) - , mUpdatePending(false) -{ - mWindowType = mReceiver->WindowType(); -} - -MozQWidget::~MozQWidget() -{ -} - -void MozQWidget::render(QPainter* painter) -{ - Q_UNUSED(painter); -} - -void MozQWidget::renderLater() -{ - if (!isExposed() || eWindowType_child != mWindowType || !isVisible()) { - return; - } - - if (!mUpdatePending) { - mUpdatePending = true; - QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); - } -} - -void MozQWidget::renderNow() -{ - if (!isExposed() || eWindowType_child != mWindowType || !isVisible()) { - return; - } - - mReceiver->OnPaint(); -} - -bool MozQWidget::event(QEvent* event) -{ - switch (event->type()) { - case QEvent::UpdateRequest: - mUpdatePending = false; - renderNow(); - return true; - default: - return QWindow::event(event); - } -} - -void MozQWidget::exposeEvent(QExposeEvent* event) -{ - Q_UNUSED(event); - if (!isExposed() || eWindowType_child != mWindowType || !isVisible()) { - return; - } - LOG(("MozQWidget::%s [%p] flags:%x\n", __FUNCTION__, (void *)this, flags())); - renderNow(); - -} - -void MozQWidget::resizeEvent(QResizeEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->resizeEvent(event); - QWindow::resizeEvent(event); -} - -void MozQWidget::focusInEvent(QFocusEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->focusInEvent(event); - QWindow::focusInEvent(event); -} - -void MozQWidget::focusOutEvent(QFocusEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->focusOutEvent(event); - QWindow::focusOutEvent(event); -} - -void MozQWidget::hideEvent(QHideEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->hideEvent(event); - QWindow::hideEvent(event); -} - -void MozQWidget::keyPressEvent(QKeyEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->keyPressEvent(event); - QWindow::keyPressEvent(event); -} - -void MozQWidget::keyReleaseEvent(QKeyEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->keyReleaseEvent(event); - QWindow::keyReleaseEvent(event); -} - -void MozQWidget::mouseDoubleClickEvent(QMouseEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->mouseDoubleClickEvent(event); - QWindow::mouseDoubleClickEvent(event); -} - -void MozQWidget::mouseMoveEvent(QMouseEvent* event) -{ - mReceiver->mouseMoveEvent(event); - QWindow::mouseMoveEvent(event); -} - -void MozQWidget::mousePressEvent(QMouseEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->mousePressEvent(event); - QWindow::mousePressEvent(event); -} - -void MozQWidget::mouseReleaseEvent(QMouseEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->mouseReleaseEvent(event); - QWindow::mouseReleaseEvent(event); -} - -void MozQWidget::moveEvent(QMoveEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->moveEvent(event); - QWindow::moveEvent(event); -} - -void MozQWidget::showEvent(QShowEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->showEvent(event); - QWindow::showEvent(event); -} - -void MozQWidget::wheelEvent(QWheelEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - mReceiver->wheelEvent(event); - QWindow::wheelEvent(event); -} - -void MozQWidget::tabletEvent(QTabletEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - QWindow::tabletEvent(event); -} - -void MozQWidget::touchEvent(QTouchEvent* event) -{ - LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this)); - QWindow::touchEvent(event); -} - -void MozQWidget::SetCursor(nsCursor aCursor) -{ - Qt::CursorShape cursor = Qt::ArrowCursor; - switch(aCursor) { - case eCursor_standard: - cursor = Qt::ArrowCursor; - break; - case eCursor_wait: - cursor = Qt::WaitCursor; - break; - case eCursor_select: - cursor = Qt::IBeamCursor; - break; - case eCursor_hyperlink: - cursor = Qt::PointingHandCursor; - break; - case eCursor_ew_resize: - cursor = Qt::SplitHCursor; - break; - case eCursor_ns_resize: - cursor = Qt::SplitVCursor; - break; - case eCursor_nw_resize: - case eCursor_se_resize: - cursor = Qt::SizeBDiagCursor; - break; - case eCursor_ne_resize: - case eCursor_sw_resize: - cursor = Qt::SizeFDiagCursor; - break; - case eCursor_crosshair: - case eCursor_move: - cursor = Qt::SizeAllCursor; - break; - case eCursor_help: - cursor = Qt::WhatsThisCursor; - break; - case eCursor_copy: - case eCursor_alias: - break; - case eCursor_context_menu: - case eCursor_cell: - case eCursor_grab: - case eCursor_grabbing: - case eCursor_spinning: - case eCursor_zoom_in: - case eCursor_zoom_out: - - default: - break; - } - - setCursor(cursor); -} diff --git a/widget/qt/mozqwidget.h b/widget/qt/mozqwidget.h deleted file mode 100644 index 4f3a4c31bd46..000000000000 --- a/widget/qt/mozqwidget.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim: set ts=4 et sw=4 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef MOZQWIDGET_H -#define MOZQWIDGET_H - -#include "nsIWidget.h" - -#include - -QT_BEGIN_NAMESPACE -class QPainter; -class QExposeEvent; -class QResizeEvent; -QT_END_NAMESPACE - -namespace mozilla { -namespace widget { - -class nsWindow; - -class MozQWidget : public QWindow -{ - Q_OBJECT -public: - explicit MozQWidget(nsWindow* aReceiver, QWindow* aParent = 0); - ~MozQWidget(); - - virtual void render(QPainter* painter); - - virtual nsWindow* getReceiver() { return mReceiver; }; - virtual void dropReceiver() { mReceiver = nullptr; }; - virtual void SetCursor(nsCursor aCursor); - -public Q_SLOTS: - void renderLater(); - void renderNow(); - -protected: - virtual bool event(QEvent* event); - virtual void exposeEvent(QExposeEvent* event); - virtual void focusInEvent(QFocusEvent* event); - virtual void focusOutEvent(QFocusEvent* event); - virtual void hideEvent(QHideEvent* event); - virtual void keyPressEvent(QKeyEvent* event); - virtual void keyReleaseEvent(QKeyEvent* event); - virtual void mouseDoubleClickEvent(QMouseEvent* event); - virtual void mouseMoveEvent(QMouseEvent* event); - virtual void mousePressEvent(QMouseEvent* event); - virtual void mouseReleaseEvent(QMouseEvent* event); - virtual void moveEvent(QMoveEvent* event); - virtual void resizeEvent(QResizeEvent* event); - virtual void showEvent(QShowEvent* event); - virtual void tabletEvent(QTabletEvent* event); - virtual void touchEvent(QTouchEvent* event); - virtual void wheelEvent(QWheelEvent* event); - -private: - nsWindow* mReceiver; - bool mUpdatePending; - nsWindowType mWindowType; -}; - -} // namespace widget -} // namespace mozilla - -#endif // MOZQWIDGET_H - diff --git a/widget/qt/nsAppShell.cpp b/widget/qt/nsAppShell.cpp deleted file mode 100644 index 5b815d4a34b0..000000000000 --- a/widget/qt/nsAppShell.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsAppShell.h" -#include -#include -#include -#include - -#include -#include - -#include "prenv.h" -#include "nsQAppInstance.h" - -#ifdef MOZ_LOGGING -#include "mozilla/Logging.h" -#endif - -PRLogModuleInfo *gWidgetLog = nullptr; -PRLogModuleInfo *gWidgetFocusLog = nullptr; -PRLogModuleInfo *gWidgetIMLog = nullptr; -PRLogModuleInfo *gWidgetDrawLog = nullptr; - -static int sPokeEvent; - -nsAppShell::~nsAppShell() -{ - nsQAppInstance::Release(); -} - -nsresult -nsAppShell::Init() -{ - if (!gWidgetLog) - gWidgetLog = PR_NewLogModule("Widget"); - if (!gWidgetFocusLog) - gWidgetFocusLog = PR_NewLogModule("WidgetFocus"); - if (!gWidgetIMLog) - gWidgetIMLog = PR_NewLogModule("WidgetIM"); - if (!gWidgetDrawLog) - gWidgetDrawLog = PR_NewLogModule("WidgetDraw"); - - sPokeEvent = QEvent::registerEventType(); - - nsQAppInstance::AddRef(); - - return nsBaseAppShell::Init(); -} - -void -nsAppShell::ScheduleNativeEventCallback() -{ - QCoreApplication::postEvent(this, - new QEvent((QEvent::Type) sPokeEvent)); -} - - -bool -nsAppShell::ProcessNextNativeEvent(bool mayWait) -{ - QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents; - - if (mayWait) - flags |= QEventLoop::WaitForMoreEvents; - - QAbstractEventDispatcher *dispatcher = QAbstractEventDispatcher::instance(QThread::currentThread()); - if (!dispatcher) - return false; - - return dispatcher->processEvents(flags) ? true : false; -} - -bool -nsAppShell::event (QEvent *e) -{ - if (e->type() == sPokeEvent) { - NativeEventCallback(); - return true; - } - - return false; -} diff --git a/widget/qt/nsAppShell.h b/widget/qt/nsAppShell.h deleted file mode 100644 index 2d2f37d75864..000000000000 --- a/widget/qt/nsAppShell.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsAppShell_h__ -#define nsAppShell_h__ - -#include -#include "nsBaseAppShell.h" -#include "nsCOMPtr.h" - -/** - * Native QT Application shell wrapper - */ - -class nsAppShell : public QObject, - public nsBaseAppShell -{ - Q_OBJECT - -public: - nsAppShell() { }; - - nsresult Init(); - - virtual bool event (QEvent *e); - -protected: - virtual void ScheduleNativeEventCallback(); - virtual bool ProcessNextNativeEvent(bool mayWait); - virtual ~nsAppShell(); -}; - - -#endif // nsAppShell_h__ - diff --git a/widget/qt/nsBidiKeyboard.cpp b/widget/qt/nsBidiKeyboard.cpp deleted file mode 100644 index 92baf8eb39da..000000000000 --- a/widget/qt/nsBidiKeyboard.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include - -#include "nsBidiKeyboard.h" - -NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard) - -nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard() -{ - Reset(); -} - -nsBidiKeyboard::~nsBidiKeyboard() -{ -} - -NS_IMETHODIMP nsBidiKeyboard::Reset() -{ - return NS_OK; -} - -NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(bool *aIsRTL) -{ - *aIsRTL = false; - - QInputMethod* input = qApp->inputMethod(); - Qt::LayoutDirection layoutDir = input ? input->inputDirection() : Qt::LeftToRight; - - if (layoutDir == Qt::RightToLeft) { - *aIsRTL = true; - } - - return NS_OK; -} - -NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) -{ - // not implemented yet - return NS_ERROR_NOT_IMPLEMENTED; -} diff --git a/widget/qt/nsBidiKeyboard.h b/widget/qt/nsBidiKeyboard.h deleted file mode 100644 index c22bf4ab8c10..000000000000 --- a/widget/qt/nsBidiKeyboard.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __nsBidiKeyboard -#define __nsBidiKeyboard -#include "nsIBidiKeyboard.h" - -class nsBidiKeyboard : public nsIBidiKeyboard -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIBIDIKEYBOARD - - nsBidiKeyboard(); - -protected: - virtual ~nsBidiKeyboard(); -}; - - -#endif // __nsBidiKeyboard diff --git a/widget/qt/nsClipboard.cpp b/widget/qt/nsClipboard.cpp deleted file mode 100644 index 797524fef53a..000000000000 --- a/widget/qt/nsClipboard.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gfxPlatform.h" -#include "mozilla/ArrayUtils.h" -#include "mozilla/gfx/2D.h" - -#include "nsClipboard.h" -#include "nsISupportsPrimitives.h" -#include "nsXPIDLString.h" -#include "nsPrimitiveHelpers.h" -#include "nsIInputStream.h" -#include "nsReadableUtils.h" -#include "nsStringStream.h" -#include "nsComponentManagerUtils.h" - -#include "imgIContainer.h" - -using namespace mozilla; -using namespace mozilla::gfx; - -NS_IMPL_ISUPPORTS(nsClipboard, nsIClipboard) - -//------------------------------------------------------------------------- -// -// nsClipboard constructor -// -//------------------------------------------------------------------------- -nsClipboard::nsClipboard() : nsIClipboard(), - mSelectionOwner(nullptr), - mGlobalOwner(nullptr), - mSelectionTransferable(nullptr), - mGlobalTransferable(nullptr) -{ - // No implementation needed -} - -//------------------------------------------------------------------------- -// -// nsClipboard destructor -// -//------------------------------------------------------------------------- -nsClipboard::~nsClipboard() -{ -} - -static inline QImage::Format -_moz2dformat_to_qformat(SurfaceFormat aFormat) -{ - switch (aFormat) { - case SurfaceFormat::B8G8R8A8: - return QImage::Format_ARGB32_Premultiplied; - case SurfaceFormat::B8G8R8X8: - return QImage::Format_ARGB32; - case SurfaceFormat::R5G6B5_UINT16: - return QImage::Format_RGB16; - default: - return QImage::Format_Invalid; - } -} - -// nsClipboard::SetNativeClipboardData ie. Copy - -NS_IMETHODIMP -nsClipboard::SetNativeClipboardData( nsITransferable *aTransferable, - QClipboard::Mode clipboardMode ) -{ - if (nullptr == aTransferable) - { - NS_WARNING("nsClipboard::SetNativeClipboardData(): no transferable!"); - return NS_ERROR_FAILURE; - } - - // get flavor list that includes all flavors that can be written (including - // ones obtained through conversion) - nsCOMPtr flavorList; - nsresult rv = aTransferable->FlavorsTransferableCanExport( getter_AddRefs(flavorList) ); - - if (NS_FAILED(rv)) - { - NS_WARNING("nsClipboard::SetNativeClipboardData(): no FlavorsTransferable !"); - return NS_ERROR_FAILURE; - } - - QClipboard *cb = QGuiApplication::clipboard(); - QMimeData *mimeData = new QMimeData; - - uint32_t flavorCount = 0; - flavorList->Count(&flavorCount); - bool imageAdded = false; - - for (uint32_t i = 0; i < flavorCount; ++i) - { - nsCOMPtr genericFlavor; - flavorList->GetElementAt(i,getter_AddRefs(genericFlavor)); - nsCOMPtr currentFlavor(do_QueryInterface(genericFlavor)); - - if (currentFlavor) - { - // flavorStr is the mime type - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - - // Clip is the data which will be sent to the clipboard - nsCOMPtr clip; - // len is the length of the data - uint32_t len; - - // Unicode text? - if (!strcmp(flavorStr.get(), kUnicodeMime)) - { - rv = aTransferable->GetTransferData(flavorStr,getter_AddRefs(clip),&len); - nsCOMPtr wideString; - wideString = do_QueryInterface(clip); - if (!wideString || NS_FAILED(rv)) - continue; - - nsAutoString utf16string; - wideString->GetData(utf16string); - QString str = QString::fromUtf16((const ushort*)utf16string.get()); - - // Add text to the mimeData - mimeData->setText(str); - } - - // html? - else if (!strcmp(flavorStr.get(), kHTMLMime)) - { - rv = aTransferable->GetTransferData(flavorStr,getter_AddRefs(clip),&len); - nsCOMPtr wideString; - wideString = do_QueryInterface(clip); - if (!wideString || NS_FAILED(rv)) - continue; - - nsAutoString utf16string; - wideString->GetData(utf16string); - QString str = QString::fromUtf16((const ushort*)utf16string.get()); - - // Add html to the mimeData - mimeData->setHtml(str); - } - - // image? - else if (!imageAdded // image is added only once to the clipboard - && (!strcmp(flavorStr.get(), kNativeImageMime) - || !strcmp(flavorStr.get(), kPNGImageMime) - || !strcmp(flavorStr.get(), kJPEGImageMime) - || !strcmp(flavorStr.get(), kJPGImageMime) - || !strcmp(flavorStr.get(), kGIFImageMime)) - ) - { - // Look through our transfer data for the image - static const char* const imageMimeTypes[] = { - kNativeImageMime, kPNGImageMime, kJPEGImageMime, kJPGImageMime, kGIFImageMime }; - nsCOMPtr ptrPrimitive; - for (uint32_t i = 0; !ptrPrimitive && i < ArrayLength(imageMimeTypes); i++) - { - aTransferable->GetTransferData(imageMimeTypes[i], getter_AddRefs(clip), &len); - ptrPrimitive = do_QueryInterface(clip); - } - - if (!ptrPrimitive) - continue; - - nsCOMPtr primitiveData; - ptrPrimitive->GetData(getter_AddRefs(primitiveData)); - nsCOMPtr image(do_QueryInterface(primitiveData)); - if (!image) // Not getting an image for an image mime type!? - continue; - - RefPtr surface = - image->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE); - if (!surface) - continue; - - RefPtr dataSurface = - surface->GetDataSurface(); - if (!dataSurface) - continue; - - DataSourceSurface::MappedSurface map; - if (!dataSurface->Map(DataSourceSurface::MapType::READ, &map)) - continue; - - QImage qImage(map.mData, - dataSurface->GetSize().width, - dataSurface->GetSize().height, - map.mStride, - _moz2dformat_to_qformat(dataSurface->GetFormat())); - - dataSurface->Unmap(); - - // Add image to the mimeData - mimeData->setImageData(qImage); - imageAdded = true; - } - - // Other flavors, adding data to clipboard "as is" - else - { - rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(clip), &len); - // nothing found? - if (!clip || NS_FAILED(rv)) - continue; - - void *primitive_data = nullptr; - nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr.get(), clip, - &primitive_data, len); - - if (primitive_data) - { - QByteArray data ((const char *)primitive_data, len); - // Add data to the mimeData - mimeData->setData(flavorStr.get(), data); - free(primitive_data); - } - } - } - } - - // If we have some mime data, add it to the clipboard - if(!mimeData->formats().isEmpty()) - cb->setMimeData(mimeData, clipboardMode); - else - delete mimeData; - - return NS_OK; -} - -// nsClipboard::GetNativeClipboardData ie. Paste -// -NS_IMETHODIMP -nsClipboard::GetNativeClipboardData(nsITransferable *aTransferable, - QClipboard::Mode clipboardMode) -{ - if (nullptr == aTransferable) - { - NS_WARNING("GetNativeClipboardData: Transferable is null!"); - return NS_ERROR_FAILURE; - } - - // get flavor list that includes all acceptable flavors (including - // ones obtained through conversion) - nsCOMPtr flavorList; - nsresult errCode = aTransferable->FlavorsTransferableCanImport( - getter_AddRefs(flavorList)); - - if (NS_FAILED(errCode)) - { - NS_WARNING("nsClipboard::GetNativeClipboardData(): no FlavorsTransferable!"); - return NS_ERROR_FAILURE; - } - - QClipboard *cb = QGuiApplication::clipboard(); - const QMimeData *mimeData = cb->mimeData(clipboardMode); - - // Walk through flavors and see which flavor matches the one being pasted - uint32_t flavorCount; - flavorList->Count(&flavorCount); - nsAutoCString foundFlavor; - - for (uint32_t i = 0; i < flavorCount; ++i) - { - nsCOMPtr genericFlavor; - flavorList->GetElementAt(i,getter_AddRefs(genericFlavor)); - nsCOMPtr currentFlavor(do_QueryInterface( genericFlavor) ); - - if (currentFlavor) - { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - - // Ok, so which flavor the data being pasted could be? - // Text? - if (!strcmp(flavorStr.get(), kUnicodeMime) && mimeData->hasText()) - { - // Clipboard has text and flavor accepts text, so lets - // handle the data as text - foundFlavor = nsAutoCString(flavorStr); - - // Get the text data from clipboard - QString text = mimeData->text(); - const QChar *unicode = text.unicode(); - // Is there a more correct way to get the size in UTF16? - uint32_t len = (uint32_t) 2*text.size(); - - // And then to genericDataWrapper - nsCOMPtr genericDataWrapper; - nsPrimitiveHelpers::CreatePrimitiveForData( - foundFlavor.get(), - (void*)unicode, - len, - getter_AddRefs(genericDataWrapper)); - // Data is good, set it to the transferable - aTransferable->SetTransferData(foundFlavor.get(), - genericDataWrapper,len); - // And thats all - break; - } - - // html? - if (!strcmp(flavorStr.get(), kHTMLMime) && mimeData->hasHtml()) - { - // Clipboard has text/html and flavor accepts text/html, so lets - // handle the data as text/html - foundFlavor = nsAutoCString(flavorStr); - - // Get the text data from clipboard - QString html = mimeData->html(); - const QChar *unicode = html.unicode(); - // Is there a more correct way to get the size in UTF16? - uint32_t len = (uint32_t) 2*html.size(); - - // And then to genericDataWrapper - nsCOMPtr genericDataWrapper; - nsPrimitiveHelpers::CreatePrimitiveForData( - foundFlavor.get(), - (void*)unicode, - len, - getter_AddRefs(genericDataWrapper)); - // Data is good, set it to the transferable - aTransferable->SetTransferData(foundFlavor.get(), - genericDataWrapper,len); - // And thats all - break; - } - - // Image? - if (( !strcmp(flavorStr.get(), kJPEGImageMime) - || !strcmp(flavorStr.get(), kJPGImageMime) - || !strcmp(flavorStr.get(), kPNGImageMime) - || !strcmp(flavorStr.get(), kGIFImageMime)) - && mimeData->hasImage()) - { - // Try to retrieve an image from clipboard - QImage image = cb->image(); - if(image.isNull()) - continue; - - // Lets set the image format - QByteArray imageFormat; - if (!strcmp(flavorStr.get(), kJPEGImageMime) || !strcmp(flavorStr.get(), kJPGImageMime)) - imageFormat = "jpeg"; - else if (!strcmp(flavorStr.get(), kPNGImageMime)) - imageFormat = "png"; - else if (!strcmp(flavorStr.get(), kGIFImageMime)) - imageFormat = "gif"; - else - continue; - - // Write image from clippboard to a QByteArrayBuffer - QByteArray imageData; - QBuffer imageBuffer(&imageData); - QImageWriter imageWriter(&imageBuffer, imageFormat); - if(!imageWriter.write(image)) - continue; - - // Add the data to inputstream - nsCOMPtr byteStream; - NS_NewByteInputStream(getter_AddRefs(byteStream), imageData.constData(), - imageData.size(), NS_ASSIGNMENT_COPY); - // Data is good, set it to the transferable - aTransferable->SetTransferData(flavorStr, byteStream, sizeof(nsIInputStream*)); - - imageBuffer.close(); - - // And thats all - break; - } - - // Other mimetype? - // Trying to forward the data "as is" - if(mimeData->hasFormat(flavorStr.get())) - { - // get the data from the clipboard - QByteArray clipboardData = mimeData->data(flavorStr.get()); - // And add it to genericDataWrapper - nsCOMPtr genericDataWrapper; - nsPrimitiveHelpers::CreatePrimitiveForData( - foundFlavor.get(), - (void*) clipboardData.data(), - clipboardData.size(), - getter_AddRefs(genericDataWrapper)); - - // Data is good, set it to the transferable - aTransferable->SetTransferData(foundFlavor.get(), - genericDataWrapper,clipboardData.size()); - // And thats all - break; - } - } - } - - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength, - int32_t aWhichClipboard, bool *_retval) -{ - *_retval = false; - if (aWhichClipboard != kGlobalClipboard) - return NS_OK; - - // Which kind of data in the clipboard - QClipboard *cb = QGuiApplication::clipboard(); - const QMimeData *mimeData = cb->mimeData(); - const char *flavor=nullptr; - QStringList formats = mimeData->formats(); - for (uint32_t i = 0; i < aLength; ++i) - { - flavor = aFlavorList[i]; - if (flavor) - { - QString qflavor(flavor); - - if (strcmp(flavor,kTextMime) == 0) - { - NS_WARNING("DO NOT USE THE text/plain DATA FLAVOR ANY MORE. USE text/unicode INSTEAD"); - } - - // QClipboard says it has text/plain, mozilla wants to - // know if the data is text/unicode -> interpret text/plain to text/unicode - if (formats.contains(qflavor) || - strcmp(flavor, kUnicodeMime) == 0) - { - // A match has been found, return' - *_retval = true; - break; - } - } - } - return NS_OK; -} - -/** - * Sets the transferable object - */ -NS_IMETHODIMP -nsClipboard::SetData(nsITransferable *aTransferable, - nsIClipboardOwner *aOwner, - int32_t aWhichClipboard) -{ - // See if we can short cut - if ( - (aWhichClipboard == kGlobalClipboard - && aTransferable == mGlobalTransferable.get() - && aOwner == mGlobalOwner.get() - ) - || - (aWhichClipboard == kSelectionClipboard - && aTransferable == mSelectionTransferable.get() - && aOwner == mSelectionOwner.get() - ) - ) - { - return NS_OK; - } - - EmptyClipboard(aWhichClipboard); - - QClipboard::Mode mode; - - if (kGlobalClipboard == aWhichClipboard) - { - mGlobalOwner = aOwner; - mGlobalTransferable = aTransferable; - - mode = QClipboard::Clipboard; - } - else - { - mSelectionOwner = aOwner; - mSelectionTransferable = aTransferable; - - mode = QClipboard::Selection; - } - return SetNativeClipboardData( aTransferable, mode ); -} - -/** - * Gets the transferable object - */ -NS_IMETHODIMP -nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard) -{ - if (nullptr != aTransferable) - { - QClipboard::Mode mode; - if (kGlobalClipboard == aWhichClipboard) - { - mode = QClipboard::Clipboard; - } - else - { - mode = QClipboard::Selection; - } - return GetNativeClipboardData(aTransferable, mode); - } - else - { - NS_WARNING("nsClipboard::GetData(), aTransferable is NULL."); - } - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsClipboard::EmptyClipboard(int32_t aWhichClipboard) -{ - if (aWhichClipboard == kSelectionClipboard) - { - if (mSelectionOwner) - { - mSelectionOwner->LosingOwnership(mSelectionTransferable); - mSelectionOwner = nullptr; - } - mSelectionTransferable = nullptr; - } - else - { - if (mGlobalOwner) - { - mGlobalOwner->LosingOwnership(mGlobalTransferable); - mGlobalOwner = nullptr; - } - mGlobalTransferable = nullptr; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::SupportsSelectionClipboard(bool *_retval) -{ - NS_ENSURE_ARG_POINTER(_retval); - - QClipboard *cb = QGuiApplication::clipboard(); - if (cb->supportsSelection()) - { - *_retval = true; // we support the selection clipboard - } - else - { - *_retval = false; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsClipboard::SupportsFindClipboard(bool* _retval) -{ - NS_ENSURE_ARG_POINTER(_retval); - - *_retval = false; - return NS_OK; -} diff --git a/widget/qt/nsClipboard.h b/widget/qt/nsClipboard.h deleted file mode 100644 index d348c4b551af..000000000000 --- a/widget/qt/nsClipboard.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsClipboard_h__ -#define nsClipboard_h__ - -#include "nsIClipboard.h" -#include "nsITransferable.h" -#include "nsIClipboardOwner.h" -#include "nsCOMPtr.h" - -#include - -/* Native Qt Clipboard wrapper */ -class nsClipboard : public nsIClipboard -{ -public: - nsClipboard(); - - //nsISupports - NS_DECL_ISUPPORTS - - // nsIClipboard - NS_DECL_NSICLIPBOARD - -protected: - virtual ~nsClipboard(); - - NS_IMETHOD SetNativeClipboardData(nsITransferable *aTransferable, - QClipboard::Mode cbMode); - NS_IMETHOD GetNativeClipboardData(nsITransferable *aTransferable, - QClipboard::Mode cbMode); - - nsCOMPtr mSelectionOwner; - nsCOMPtr mGlobalOwner; - nsCOMPtr mSelectionTransferable; - nsCOMPtr mGlobalTransferable; -}; - -#endif // nsClipboard_h__ diff --git a/widget/qt/nsDeviceContextSpecQt.cpp b/widget/qt/nsDeviceContextSpecQt.cpp deleted file mode 100644 index 1ce9abd60e11..000000000000 --- a/widget/qt/nsDeviceContextSpecQt.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - -#include -#include - -#define SET_PRINTER_FEATURES_VIA_PREFS 1 -#define PRINTERFEATURES_PREF "print.tmp.printerfeatures" - -#include "mozilla/gfx/PrintTargetPDF.h" -#include "mozilla/Logging.h" - -#include "plstr.h" - -#include "nsDeviceContextSpecQt.h" - -#include "prenv.h" /* for PR_GetEnv */ - -#include "nsReadableUtils.h" -#include "nsStringEnumerator.h" -#include "nsIServiceManager.h" -#include "nsPrintSettingsQt.h" -#include "nsIFileStreams.h" -#include "nsIFile.h" -#include "nsTArray.h" - -#include -#include -#include - -using namespace mozilla; -using namespace mozilla::gfx; - -static PRLogModuleInfo* DeviceContextSpecQtLM = - PR_NewLogModule("DeviceContextSpecQt"); -/* Macro to make lines shorter */ -#define DO_PR_DEBUG_LOG(x) MOZ_LOG(DeviceContextSpecQtLM, mozilla::LogLevel::Debug, x) - -nsDeviceContextSpecQt::nsDeviceContextSpecQt() -{ - DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::nsDeviceContextSpecQt()\n")); -} - -nsDeviceContextSpecQt::~nsDeviceContextSpecQt() -{ - DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::~nsDeviceContextSpecQt()\n")); -} - -NS_IMPL_ISUPPORTS(nsDeviceContextSpecQt, - nsIDeviceContextSpec) - -already_AddRefed nsDeviceContextSpecQt::MakePrintTarget() -{ - double width, height; - mPrintSettings->GetEffectivePageSize(&width, &height); - - // If we're in landscape mode, we'll be rotating the output -- - // need to swap width & height. - int32_t orientation; - mPrintSettings->GetOrientation(&orientation); - if (nsIPrintSettings::kLandscapeOrientation == orientation) { - double tmp = width; - width = height; - height = tmp; - } - - // convert twips to points - width /= TWIPS_PER_POINT_FLOAT; - height /= TWIPS_PER_POINT_FLOAT; - - DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", mPath, width, height)); - - QTemporaryFile file; - if(!file.open()) { - return nullptr; - } - file.setAutoRemove(false); - - nsresult rv = NS_NewNativeLocalFile( - nsDependentCString(file.fileName().toUtf8().constData()), - false, - getter_AddRefs(mSpoolFile)); - if (NS_FAILED(rv)) { - file.remove(); - return nullptr; - } - - mSpoolName = file.fileName().toUtf8().constData(); - - mSpoolFile->SetPermissions(0600); - - nsCOMPtr stream = - do_CreateInstance("@mozilla.org/network/file-output-stream;1"); - - rv = stream->Init(mSpoolFile, -1, -1, 0); - if (NS_FAILED(rv)) - return nullptr; - - int16_t format; - mPrintSettings->GetOutputFormat(&format); - - if (format == nsIPrintSettings::kOutputFormatNative) { - if (mIsPPreview) { - // There is nothing to detect on Print Preview, use PS. - // TODO: implement for Qt? - //format = nsIPrintSettings::kOutputFormatPS; - return nullptr; - } - format = nsIPrintSettings::kOutputFormatPDF; - } - - if (format == nsIPrintSettings::kOutputFormatPDF) { - return PrintTargetPDF::CreateOrNull(stream, IntSize(width, height)); - } - - return nullptr; -} - -NS_IMETHODIMP nsDeviceContextSpecQt::Init(nsIWidget* aWidget, - nsIPrintSettings* aPS, - bool aIsPrintPreview) -{ - DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::Init(aPS=%p)\n", aPS)); - - mPrintSettings = aPS; - mIsPPreview = aIsPrintPreview; - - // This is only set by embedders - bool toFile; - aPS->GetPrintToFile(&toFile); - - mToPrinter = !toFile && !aIsPrintPreview; - - nsCOMPtr printSettingsQt(do_QueryInterface(aPS)); - if (!printSettingsQt) - return NS_ERROR_NO_INTERFACE; - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecQt::BeginDocument( - const nsAString& aTitle, - const nsAString& aPrintToFileName, - int32_t aStartPage, - int32_t aEndPage) -{ - if (mToPrinter) { - return NS_ERROR_NOT_IMPLEMENTED; - } - return NS_OK; -} - -NS_IMETHODIMP nsDeviceContextSpecQt::EndDocument() -{ - if (mToPrinter) { - return NS_ERROR_NOT_IMPLEMENTED; - } - // Handle print-to-file ourselves for the benefit of embedders - nsXPIDLString targetPath; - nsCOMPtr destFile; - mPrintSettings->GetToFileName(getter_Copies(targetPath)); - - nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(targetPath), - false, getter_AddRefs(destFile)); - NS_ENSURE_SUCCESS(rv, rv); - - nsAutoString destLeafName; - rv = destFile->GetLeafName(destLeafName); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr destDir; - rv = destFile->GetParent(getter_AddRefs(destDir)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mSpoolFile->MoveTo(destDir, destLeafName); - NS_ENSURE_SUCCESS(rv, rv); - - // This is the standard way to get the UNIX umask. Ugh. - mode_t mask = umask(0); - umask(mask); - // If you're not familiar with umasks, they contain the bits of what NOT - // to set in the permissions - // (thats because files and directories have different numbers of bits - // for their permissions) - destFile->SetPermissions(0666 & ~(mask)); - - return NS_OK; -} - -// Printer Enumerator -nsPrinterEnumeratorQt::nsPrinterEnumeratorQt() -{ -} - -nsPrinterEnumeratorQt::~nsPrinterEnumeratorQt() -{ -} - -NS_IMPL_ISUPPORTS(nsPrinterEnumeratorQt, nsIPrinterEnumerator) - -NS_IMETHODIMP nsPrinterEnumeratorQt::GetPrinterNameList( - nsIStringEnumerator** aPrinterNameList) -{ - NS_ENSURE_ARG_POINTER(aPrinterNameList); - *aPrinterNameList = nullptr; - - QList qprinters = QPrinterInfo::availablePrinters(); - if (qprinters.size() == 0) - return NS_ERROR_NOT_AVAILABLE; - - nsTArray* printers = - new nsTArray(qprinters.size()); - - for (int32_t i = 0; i < qprinters.size(); ++i) { - printers->AppendElement( - nsDependentString( - (const char16_t*)qprinters[i].printerName().constData())); - } - - return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers); -} - -NS_IMETHODIMP nsPrinterEnumeratorQt::GetDefaultPrinterName( - char16_t** aDefaultPrinterName) -{ - DO_PR_DEBUG_LOG(("nsPrinterEnumeratorQt::GetDefaultPrinterName()\n")); - NS_ENSURE_ARG_POINTER(aDefaultPrinterName); - - QString defprinter = QPrinterInfo::defaultPrinter().printerName(); - *aDefaultPrinterName = ToNewUnicode(nsDependentString( - (const char16_t*)defprinter.constData())); - - DO_PR_DEBUG_LOG(("GetDefaultPrinterName(): default printer='%s'.\n", - NS_ConvertUTF16toUTF8(*aDefaultPrinterName).get())); - - return NS_OK; -} - -NS_IMETHODIMP nsPrinterEnumeratorQt::InitPrintSettingsFromPrinter( - const char16_t* aPrinterName, - nsIPrintSettings* aPrintSettings) -{ - DO_PR_DEBUG_LOG(("nsPrinterEnumeratorQt::InitPrintSettingsFromPrinter()")); - // XXX Leave NS_OK for now - // Probably should use NS_ERROR_NOT_IMPLEMENTED - return NS_OK; -} diff --git a/widget/qt/nsDeviceContextSpecQt.h b/widget/qt/nsDeviceContextSpecQt.h deleted file mode 100644 index 7a39ab99f42e..000000000000 --- a/widget/qt/nsDeviceContextSpecQt.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - -#ifndef nsDeviceContextSpecQt_h___ -#define nsDeviceContextSpecQt_h___ - -#include "nsIDeviceContextSpec.h" -#include "nsIPrintSettings.h" -#include "nsIPrintOptions.h" -#include "nsCOMPtr.h" -#include "nsString.h" - -#include "nsCRT.h" /* should be ? */ - -class nsDeviceContextSpecQt : public nsIDeviceContextSpec -{ -public: - nsDeviceContextSpecQt(); - - NS_DECL_ISUPPORTS - - virtual already_AddRefed MakePrintTarget() final; - - NS_IMETHOD Init(nsIWidget* aWidget, - nsIPrintSettings* aPS, - bool aIsPrintPreview); - NS_IMETHOD BeginDocument(const nsAString& aTitle, - const nsAString& aPrintToFileName, - int32_t aStartPage, - int32_t aEndPage); - NS_IMETHOD EndDocument(); - NS_IMETHOD BeginPage() { return NS_OK; } - NS_IMETHOD EndPage() { return NS_OK; } - -protected: - virtual ~nsDeviceContextSpecQt(); - - nsCOMPtr mPrintSettings; - bool mToPrinter : 1; /* If true, print to printer */ - bool mIsPPreview : 1; /* If true, is print preview */ - char mPath[PATH_MAX]; /* If toPrinter = false, dest file */ - char mPrinter[256]; /* Printer name */ - nsCString mSpoolName; - nsCOMPtr mSpoolFile; -}; - -class nsPrinterEnumeratorQt : public nsIPrinterEnumerator -{ -public: - nsPrinterEnumeratorQt(); - NS_DECL_ISUPPORTS - NS_DECL_NSIPRINTERENUMERATOR - -protected: - virtual ~nsPrinterEnumeratorQt(); - -}; - -#endif /* !nsDeviceContextSpecQt_h___ */ diff --git a/widget/qt/nsIdleServiceQt.cpp b/widget/qt/nsIdleServiceQt.cpp deleted file mode 100644 index b9fea1fa35ee..000000000000 --- a/widget/qt/nsIdleServiceQt.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifdef MOZ_X11 -#include "mozilla/X11Util.h" -#endif -#include "nsIdleServiceQt.h" -#include "nsIServiceManager.h" -#include "nsDebug.h" -#include "prlink.h" - -#if defined(MOZ_X11) -typedef bool (*_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); - -static _XScreenSaverQueryExtension_fn _XSSQueryExtension = nullptr; -static _XScreenSaverAllocInfo_fn _XSSAllocInfo = nullptr; -static _XScreenSaverQueryInfo_fn _XSSQueryInfo = nullptr; -#endif - -static bool sInitialized = false; - -NS_IMPL_ISUPPORTS_INHERITED0(nsIdleServiceQt, nsIdleService) - -nsIdleServiceQt::nsIdleServiceQt() -#if defined(MOZ_X11) - : mXssInfo(nullptr) -#endif -{ -} - -static void Initialize() -{ - sInitialized = true; - -#if 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"); - _XSSAllocInfo = (_XScreenSaverAllocInfo_fn) - PR_FindFunctionSymbol(xsslib, "XScreenSaverAllocInfo"); - _XSSQueryInfo = (_XScreenSaverQueryInfo_fn) - PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryInfo"); -#endif -} - -nsIdleServiceQt::~nsIdleServiceQt() -{ -#if 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) { - PR_UnloadLibrary(xsslib); - xsslib = nullptr; - } -#endif -#endif -} - -bool -nsIdleServiceQt::PollIdleTime(uint32_t *aIdleTime) -{ -#if defined(MOZ_X11) - // Ask xscreensaver about idle time: - *aIdleTime = 0; - - // We might not have a display (cf. in xpcshell) - Display *dplay = mozilla::DefaultXDisplay(); - if (!dplay) { - return false; - } - - if (!sInitialized) { - Initialize(); - } - if (!_XSSQueryExtension || !_XSSAllocInfo || !_XSSQueryInfo) { - return false; - } - - int event_base, error_base; - if (_XSSQueryExtension(dplay, &event_base, &error_base)) { - if (!mXssInfo) - mXssInfo = _XSSAllocInfo(); - if (!mXssInfo) - return false; - - _XSSQueryInfo(dplay, RootWindowOfScreen(DefaultScreenOfDisplay(mozilla::DefaultXDisplay())), mXssInfo); - *aIdleTime = mXssInfo->idle; - return true; - } -#endif - - return false; -} - -bool -nsIdleServiceQt::UsePollMode() -{ -#if defined(MOZ_X11) - return false; -#endif - return true; -} - diff --git a/widget/qt/nsIdleServiceQt.h b/widget/qt/nsIdleServiceQt.h deleted file mode 100644 index f947b56e02e0..000000000000 --- a/widget/qt/nsIdleServiceQt.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsIdleServiceQt_h__ -#define nsIdleServiceQt_h__ - -#include "nsIdleService.h" - -#if defined(MOZ_X11) -#include -#include - -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 - unsigned long idle; // milliseconds idle - unsigned long event_mask; // event stuff -} XScreenSaverInfo; -#endif - -class nsIdleServiceQt : public nsIdleService -{ -public: - NS_DECL_ISUPPORTS_INHERITED - - bool PollIdleTime(uint32_t* aIdleTime); - - static already_AddRefed GetInstance() - { - RefPtr idleService = - nsIdleService::GetInstance().downcast(); - if (!idleService) { - idleService = new nsIdleServiceQt(); - } - - return idleService.forget(); - } - -private: -#if defined(MOZ_X11) - XScreenSaverInfo* mXssInfo; -#endif - -protected: - nsIdleServiceQt(); - virtual ~nsIdleServiceQt(); - bool UsePollMode(); -}; - -#endif // nsIdleServiceQt_h__ diff --git a/widget/qt/nsLookAndFeel.cpp b/widget/qt/nsLookAndFeel.cpp deleted file mode 100644 index 50d943e8dc2c..000000000000 --- a/widget/qt/nsLookAndFeel.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright 2012 Mozilla Foundation and Mozilla contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#include "nsLookAndFeel.h" -#include "nsStyleConsts.h" -#include "gfxFont.h" -#include "gfxFontConstants.h" -#include "mozilla/gfx/2D.h" - -static const char16_t UNICODE_BULLET = 0x2022; - -#define QCOLOR_TO_NS_RGB(c) \ - ((nscolor)NS_RGB(c.red(),c.green(),c.blue())) - -nsLookAndFeel::nsLookAndFeel() - : nsXPLookAndFeel() -{ -} - -nsLookAndFeel::~nsLookAndFeel() -{ -} - -nsresult -nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) -{ - nsresult rv = NS_OK; - -#define BG_PRELIGHT_COLOR NS_RGB(0xee,0xee,0xee) -#define FG_PRELIGHT_COLOR NS_RGB(0x77,0x77,0x77) -#define RED_COLOR NS_RGB(0xff,0x00,0x00) - - QPalette palette = QGuiApplication::palette(); - - switch (aID) { - // These colors don't seem to be used for anything anymore in Mozilla - // (except here at least TextSelectBackground and TextSelectForeground) - // The CSS2 colors below are used. - case eColorID_WindowBackground: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_WindowForeground: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText)); - break; - case eColorID_WidgetBackground: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_WidgetForeground: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText)); - break; - case eColorID_WidgetSelectBackground: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_WidgetSelectForeground: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText)); - break; - case eColorID_Widget3DHighlight: - aColor = NS_RGB(0xa0,0xa0,0xa0); - break; - case eColorID_Widget3DShadow: - aColor = NS_RGB(0x40,0x40,0x40); - break; - case eColorID_TextBackground: - // not used? - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_TextForeground: - // not used? - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText)); - break; - case eColorID_TextSelectBackground: - case eColorID_IMESelectedRawTextBackground: - case eColorID_IMESelectedConvertedTextBackground: - // still used - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight)); - break; - case eColorID_TextSelectForeground: - case eColorID_IMESelectedRawTextForeground: - case eColorID_IMESelectedConvertedTextForeground: - // still used - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText)); - break; - case eColorID_IMERawInputBackground: - case eColorID_IMEConvertedTextBackground: - aColor = NS_TRANSPARENT; - break; - case eColorID_IMERawInputForeground: - case eColorID_IMEConvertedTextForeground: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case eColorID_IMERawInputUnderline: - case eColorID_IMEConvertedTextUnderline: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case eColorID_IMESelectedRawTextUnderline: - case eColorID_IMESelectedConvertedTextUnderline: - aColor = NS_TRANSPARENT; - break; - case eColorID_SpellCheckerUnderline: - aColor = RED_COLOR; - break; - - // css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors - case eColorID_activeborder: - // active window border - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_activecaption: - // active window caption background - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_appworkspace: - // MDI background color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_background: - // desktop background - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_captiontext: - // text in active window caption, size box, and scrollbar arrow box (!) - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - case eColorID_graytext: - // disabled text in windows, menus, etc. - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Text)); - break; - case eColorID_highlight: - // background of selected item - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight)); - break; - case eColorID_highlighttext: - // text of selected item - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText)); - break; - case eColorID_inactiveborder: - // inactive window border - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Window)); - break; - case eColorID_inactivecaption: - // inactive window caption - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Window)); - break; - case eColorID_inactivecaptiontext: - // text in inactive window caption - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Disabled, QPalette::Text)); - break; - case eColorID_infobackground: - // tooltip background color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ToolTipBase)); - break; - case eColorID_infotext: - // tooltip text color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ToolTipText)); - break; - case eColorID_menu: - // menu background - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID_menutext: - // menu text - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - case eColorID_scrollbar: - // scrollbar gray area - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Mid)); - break; - - case eColorID_threedface: - case eColorID_buttonface: - // 3-D face color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button)); - break; - - case eColorID_buttontext: - // text on push buttons - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::ButtonText)); - break; - - case eColorID_buttonhighlight: - // 3-D highlighted edge color - case eColorID_threedhighlight: - // 3-D highlighted outer edge color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Dark)); - break; - - case eColorID_threedlightshadow: - // 3-D highlighted inner edge color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Light)); - break; - - case eColorID_buttonshadow: - // 3-D shadow edge color - case eColorID_threedshadow: - // 3-D shadow inner edge color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Dark)); - break; - - case eColorID_threeddarkshadow: - // 3-D shadow outer edge color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Shadow)); - break; - - case eColorID_window: - case eColorID_windowframe: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - - case eColorID_windowtext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - - case eColorID__moz_eventreerow: - case eColorID__moz_field: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base)); - break; - case eColorID__moz_fieldtext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - case eColorID__moz_dialog: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID__moz_dialogtext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::WindowText)); - break; - case eColorID__moz_dragtargetzone: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window)); - break; - case eColorID__moz_buttondefault: - // default button border color - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button)); - break; - case eColorID__moz_buttonhoverface: - aColor = BG_PRELIGHT_COLOR; - break; - case eColorID__moz_buttonhovertext: - aColor = FG_PRELIGHT_COLOR; - break; - case eColorID__moz_cellhighlight: - case eColorID__moz_html_cellhighlight: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Highlight)); - break; - case eColorID__moz_cellhighlighttext: - case eColorID__moz_html_cellhighlighttext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::HighlightedText)); - break; - case eColorID__moz_menuhover: - aColor = BG_PRELIGHT_COLOR; - break; - case eColorID__moz_menuhovertext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - case eColorID__moz_oddtreerow: - aColor = NS_TRANSPARENT; - break; - case eColorID__moz_nativehyperlinktext: - aColor = NS_SAME_AS_FOREGROUND_COLOR; - break; - case eColorID__moz_comboboxtext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - case eColorID__moz_combobox: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base)); - break; - case eColorID__moz_menubartext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - case eColorID__moz_menubarhovertext: - aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text)); - break; - default: - /* default color is BLACK */ - aColor = 0; - rv = NS_ERROR_FAILURE; - break; - } - - return rv; -} - -nsresult -nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) -{ - nsresult rv = nsXPLookAndFeel::GetIntImpl(aID, aResult); - if (NS_SUCCEEDED(rv)) - return rv; - - rv = NS_OK; - - switch (aID) { - case eIntID_CaretBlinkTime: - aResult = 500; - break; - - case eIntID_CaretWidth: - aResult = 1; - break; - - case eIntID_ShowCaretDuringSelection: - aResult = 0; - break; - - case eIntID_SelectTextfieldsOnKeyFocus: - // Select textfield content when focused by kbd - // used by EventStateManager::sTextfieldSelectModel - aResult = 1; - break; - - case eIntID_SubmenuDelay: - aResult = 200; - break; - - case eIntID_TooltipDelay: - aResult = 500; - break; - - case eIntID_MenusCanOverlapOSBar: - // we want XUL popups to be able to overlap the task bar. - aResult = 1; - break; - - case eIntID_ScrollArrowStyle: - aResult = eScrollArrowStyle_Single; - break; - - case eIntID_ScrollSliderStyle: - aResult = eScrollThumbStyle_Proportional; - break; - - case eIntID_TouchEnabled: - aResult = 1; - break; - - case eIntID_WindowsDefaultTheme: - case eIntID_WindowsThemeIdentifier: - case eIntID_OperatingSystemVersionIdentifier: - aResult = 0; - rv = NS_ERROR_NOT_IMPLEMENTED; - break; - - case eIntID_IMERawInputUnderlineStyle: - case eIntID_IMEConvertedTextUnderlineStyle: - aResult = NS_STYLE_TEXT_DECORATION_STYLE_SOLID; - break; - - case eIntID_IMESelectedRawTextUnderlineStyle: - case eIntID_IMESelectedConvertedTextUnderline: - aResult = NS_STYLE_TEXT_DECORATION_STYLE_NONE; - break; - - case eIntID_SpellCheckerUnderlineStyle: - aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY; - break; - - case eIntID_ScrollbarButtonAutoRepeatBehavior: - aResult = 0; - break; - - case eIntID_ContextMenuOffsetVertical: - case eIntID_ContextMenuOffsetHorizontal: - aResult = 2; - break; - - default: - aResult = 0; - rv = NS_ERROR_FAILURE; - } - - return rv; -} - -nsresult -nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult) -{ - nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult); - if (NS_SUCCEEDED(res)) - return res; - res = NS_OK; - - switch (aID) { - case eFloatID_IMEUnderlineRelativeSize: - aResult = 1.0f; - break; - case eFloatID_SpellCheckerUnderlineRelativeSize: - aResult = 1.0f; - break; - default: - aResult = -1.0; - res = NS_ERROR_FAILURE; - } - return res; -} - -/*virtual*/ -bool -nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, - gfxFontStyle& aFontStyle, - float aDevPixPerCSSPixel) -{ - QFont qFont = QGuiApplication::font(); - - NS_NAMED_LITERAL_STRING(quote, "\""); - nsString family((char16_t*)qFont.family().data()); - aFontName = quote + family + quote; - - aFontStyle.systemFont = true; - aFontStyle.style = qFont.style(); - aFontStyle.weight = qFont.weight(); - aFontStyle.stretch = qFont.stretch(); - // use pixel size directly if it is set, otherwise compute from point size - if (qFont.pixelSize() != -1) { - aFontStyle.size = qFont.pixelSize(); - } else { - aFontStyle.size = qFont.pointSizeF() * qApp->primaryScreen()->logicalDotsPerInch() / 72.0f; - } - - return true; -} - -/*virtual*/ -bool -nsLookAndFeel::GetEchoPasswordImpl() { - return true; -} - -/*virtual*/ -uint32_t -nsLookAndFeel::GetPasswordMaskDelayImpl() -{ - // Same value on Android framework - return 1500; -} - -/* virtual */ -char16_t -nsLookAndFeel::GetPasswordCharacterImpl() -{ - return UNICODE_BULLET; -} diff --git a/widget/qt/nsLookAndFeel.h b/widget/qt/nsLookAndFeel.h deleted file mode 100644 index aa7dce823cdd..000000000000 --- a/widget/qt/nsLookAndFeel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright 2012 Mozilla Foundation and Mozilla contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __nsLookAndFeel -#define __nsLookAndFeel - -#include "nsXPLookAndFeel.h" - -class nsLookAndFeel : public nsXPLookAndFeel -{ -public: - nsLookAndFeel(); - virtual ~nsLookAndFeel(); - - virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle, - float aDevPixPerCSSPixel); - virtual nsresult GetIntImpl(IntID aID, int32_t &aResult); - virtual nsresult GetFloatImpl(FloatID aID, float &aResult); - virtual bool GetEchoPasswordImpl(); - virtual uint32_t GetPasswordMaskDelayImpl(); - virtual char16_t GetPasswordCharacterImpl(); - -protected: - virtual nsresult NativeGetColor(ColorID aID, nscolor &aColor); -}; - -#endif diff --git a/widget/qt/nsPrintDialogQt.cpp b/widget/qt/nsPrintDialogQt.cpp deleted file mode 100644 index 61711e36c28e..000000000000 --- a/widget/qt/nsPrintDialogQt.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsPrintSettingsQt.h" -#include "nsPrintDialogQt.h" - -// For Qt, we only support printing to PDF, and that doesn't need a -// print dialog at this point. So, this class's methods are left -// un-implemented for now. - -NS_IMPL_ISUPPORTS(nsPrintDialogServiceQt, nsIPrintDialogService) - -nsPrintDialogServiceQt::nsPrintDialogServiceQt() -{ -} - -nsPrintDialogServiceQt::~nsPrintDialogServiceQt() -{ -} - -NS_IMETHODIMP -nsPrintDialogServiceQt::Init() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsPrintDialogServiceQt::Show(nsIDOMWindow* aParent, - nsIPrintSettings* aSettings, - nsIWebBrowserPrint* aWebBrowserPrint) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsPrintDialogServiceQt::ShowPageSetup(nsIDOMWindow* aParent, - nsIPrintSettings* aNSSettings) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} diff --git a/widget/qt/nsPrintDialogQt.h b/widget/qt/nsPrintDialogQt.h deleted file mode 100644 index fb356a5af9b0..000000000000 --- a/widget/qt/nsPrintDialogQt.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsPrintDialogQt_h__ -#define nsPrintDialogQt_h__ - -#include "nsIPrintDialogService.h" - -class nsIPrintSettings; - -class nsPrintDialogServiceQt : public nsIPrintDialogService -{ -public: - nsPrintDialogServiceQt(); - - NS_DECL_ISUPPORTS - - NS_IMETHODIMP Init(); - NS_IMETHODIMP Show(nsIDOMWindow* aParent, - nsIPrintSettings* aSettings, - nsIWebBrowserPrint* aWebBrowserPrint); - NS_IMETHODIMP ShowPageSetup(nsIDOMWindow* aParent, - nsIPrintSettings* aSettings); - -protected: - virtual ~nsPrintDialogServiceQt(); -}; - -#endif diff --git a/widget/qt/nsPrintOptionsQt.cpp b/widget/qt/nsPrintOptionsQt.cpp deleted file mode 100644 index 5cbcfcdd5fdb..000000000000 --- a/widget/qt/nsPrintOptionsQt.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsPrintSettingsQt.h" -#include "nsPrintOptionsQt.h" - -nsPrintOptionsQt::nsPrintOptionsQt() -{ -} - -nsPrintOptionsQt::~nsPrintOptionsQt() -{ -} - -nsresult nsPrintOptionsQt::_CreatePrintSettings(nsIPrintSettings** _retval) -{ - nsPrintSettingsQt* printSettings = - new nsPrintSettingsQt(); // does not initially ref count - NS_ADDREF(*_retval = printSettings); // ref count - return NS_OK; -} diff --git a/widget/qt/nsPrintOptionsQt.h b/widget/qt/nsPrintOptionsQt.h deleted file mode 100644 index 0a23abe64c00..000000000000 --- a/widget/qt/nsPrintOptionsQt.h +++ /dev/null @@ -1,20 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsPrintOptionsQt_h__ -#define nsPrintOptionsQt_h__ - -#include "nsPrintOptionsImpl.h" - -class nsPrintOptionsQt : public nsPrintOptions -{ -public: - nsPrintOptionsQt(); - virtual ~nsPrintOptionsQt(); - virtual nsresult _CreatePrintSettings(nsIPrintSettings** _retval); -}; - -#endif /* nsPrintOptionsQt_h__ */ diff --git a/widget/qt/nsPrintSettingsQt.cpp b/widget/qt/nsPrintSettingsQt.cpp deleted file mode 100644 index 680440b102f9..000000000000 --- a/widget/qt/nsPrintSettingsQt.cpp +++ /dev/null @@ -1,427 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include -#include "nsPrintSettingsQt.h" -#include "nsIFile.h" -#include "nsCRTGlue.h" - -NS_IMPL_ISUPPORTS_INHERITED(nsPrintSettingsQt, - nsPrintSettings, - nsPrintSettingsQt) - -nsPrintSettingsQt::nsPrintSettingsQt(): - mQPrinter(new QPrinter()) -{ -} - -nsPrintSettingsQt::~nsPrintSettingsQt() -{ - //smart pointer should take care of cleanup -} - -nsPrintSettingsQt::nsPrintSettingsQt(const nsPrintSettingsQt& aPS): - mQPrinter(aPS.mQPrinter) -{ -} - -nsPrintSettingsQt& -nsPrintSettingsQt::operator=(const nsPrintSettingsQt& rhs) -{ - if (this == &rhs) { - return *this; - } - - nsPrintSettings::operator=(rhs); - mQPrinter = rhs.mQPrinter; - return *this; -} - -nsresult -nsPrintSettingsQt::_Clone(nsIPrintSettings** _retval) -{ - NS_ENSURE_ARG_POINTER(_retval); - - nsPrintSettingsQt* newSettings = new nsPrintSettingsQt(*this); - *_retval = newSettings; - NS_ADDREF(*_retval); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::_Assign(nsIPrintSettings* aPS) -{ - nsPrintSettingsQt* printSettingsQt = static_cast(aPS); - if (!printSettingsQt) - return NS_ERROR_UNEXPECTED; - *this = *printSettingsQt; - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetPrintRange(int16_t* aPrintRange) -{ - NS_ENSURE_ARG_POINTER(aPrintRange); - - QPrinter::PrintRange range = mQPrinter->printRange(); - if (range == QPrinter::PageRange) { - *aPrintRange = kRangeSpecifiedPageRange; - } else if (range == QPrinter::Selection) { - *aPrintRange = kRangeSelection; - } else { - *aPrintRange = kRangeAllPages; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPrintRange(int16_t aPrintRange) -{ - if (aPrintRange == kRangeSelection) { - mQPrinter->setPrintRange(QPrinter::Selection); - } else if (aPrintRange == kRangeSpecifiedPageRange) { - mQPrinter->setPrintRange(QPrinter::PageRange); - } else { - mQPrinter->setPrintRange(QPrinter::AllPages); - } - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetStartPageRange(int32_t* aStartPageRange) -{ - NS_ENSURE_ARG_POINTER(aStartPageRange); - int32_t start = mQPrinter->fromPage(); - *aStartPageRange = start; - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetStartPageRange(int32_t aStartPageRange) -{ - int32_t endRange = mQPrinter->toPage(); - mQPrinter->setFromTo(aStartPageRange, endRange); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetEndPageRange(int32_t* aEndPageRange) -{ - NS_ENSURE_ARG_POINTER(aEndPageRange); - int32_t end = mQPrinter->toPage(); - *aEndPageRange = end; - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetEndPageRange(int32_t aEndPageRange) -{ - int32_t startRange = mQPrinter->fromPage(); - mQPrinter->setFromTo(startRange, aEndPageRange); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetPrintReversed(bool* aPrintReversed) -{ - NS_ENSURE_ARG_POINTER(aPrintReversed); - if (mQPrinter->pageOrder() == QPrinter::LastPageFirst) { - *aPrintReversed = true; - } else { - *aPrintReversed = false; - } - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPrintReversed(bool aPrintReversed) -{ - if (aPrintReversed) { - mQPrinter->setPageOrder(QPrinter::LastPageFirst); - } else { - mQPrinter->setPageOrder(QPrinter::FirstPageFirst); - } - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetPrintInColor(bool* aPrintInColor) -{ - NS_ENSURE_ARG_POINTER(aPrintInColor); - if (mQPrinter->colorMode() == QPrinter::Color) { - *aPrintInColor = true; - } else { - *aPrintInColor = false; - } - return NS_OK; -} -NS_IMETHODIMP -nsPrintSettingsQt::SetPrintInColor(bool aPrintInColor) -{ - if (aPrintInColor) { - mQPrinter->setColorMode(QPrinter::Color); - } else { - mQPrinter->setColorMode(QPrinter::GrayScale); - } - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetOrientation(int32_t* aOrientation) -{ - NS_ENSURE_ARG_POINTER(aOrientation); - QPrinter::Orientation orientation = mQPrinter->orientation(); - if (orientation == QPrinter::Landscape) { - *aOrientation = kLandscapeOrientation; - } else { - *aOrientation = kPortraitOrientation; - } - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetOrientation(int32_t aOrientation) -{ - if (aOrientation == kLandscapeOrientation) { - mQPrinter->setOrientation(QPrinter::Landscape); - } else { - mQPrinter->setOrientation(QPrinter::Portrait); - } - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetToFileName(char16_t** aToFileName) -{ - NS_ENSURE_ARG_POINTER(aToFileName); - QString filename; - filename = mQPrinter->outputFileName(); - *aToFileName = ToNewUnicode( - nsDependentString((char16_t*)filename.data())); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetToFileName(const char16_t* aToFileName) -{ - nsCOMPtr file; - nsresult rv = NS_NewLocalFile(nsDependentString(aToFileName), true, - getter_AddRefs(file)); - NS_ENSURE_SUCCESS(rv, rv); - - QString filename((const QChar*)aToFileName, NS_strlen(aToFileName)); - mQPrinter->setOutputFileName(filename); - - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetPrinterName(char16_t** aPrinter) -{ - NS_ENSURE_ARG_POINTER(aPrinter); - *aPrinter = ToNewUnicode(nsDependentString( - (const char16_t*)mQPrinter->printerName().constData())); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPrinterName(const char16_t* aPrinter) -{ - QString printername((const QChar*)aPrinter, NS_strlen(aPrinter)); - mQPrinter->setPrinterName(printername); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetNumCopies(int32_t* aNumCopies) -{ - NS_ENSURE_ARG_POINTER(aNumCopies); - *aNumCopies = mQPrinter->numCopies(); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetNumCopies(int32_t aNumCopies) -{ - mQPrinter->setNumCopies(aNumCopies); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetScaling(double* aScaling) -{ - NS_ENSURE_ARG_POINTER(aScaling); - qDebug()<paperSize(); - QString name(indexToPaperName[size]); - *aPaperName = ToNewUnicode(nsDependentString((const char16_t*)name.constData())); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPaperName(const char16_t* aPaperName) -{ - QString ref((QChar*)aPaperName, NS_strlen(aPaperName)); - for (uint32_t i = 0; i < sizeof(indexToPaperName)/sizeof(char*); i++) - { - if (ref == QString(indexToPaperName[i])) { - mQPrinter->setPageSize(indexToQtPaperEnum[i]); - return NS_OK; - } - } - return NS_ERROR_FAILURE; -} - -QPrinter::Unit GetQtUnit(int16_t aGeckoUnit) -{ - if (aGeckoUnit == nsIPrintSettings::kPaperSizeMillimeters) { - return QPrinter::Millimeter; - } else { - return QPrinter::Inch; - } -} - -#define SETUNWRITEABLEMARGIN\ - mQPrinter->setPageMargins(\ - NS_TWIPS_TO_INCHES(mUnwriteableMargin.left),\ - NS_TWIPS_TO_INCHES(mUnwriteableMargin.top),\ - NS_TWIPS_TO_INCHES(mUnwriteableMargin.right),\ - NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom),\ - QPrinter::Inch); - -NS_IMETHODIMP -nsPrintSettingsQt::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin) -{ - nsPrintSettings::SetUnwriteableMarginInTwips(aUnwriteableMargin); - SETUNWRITEABLEMARGIN - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetUnwriteableMarginTop(double aUnwriteableMarginTop) -{ - nsPrintSettings::SetUnwriteableMarginTop(aUnwriteableMarginTop); - SETUNWRITEABLEMARGIN - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft) -{ - nsPrintSettings::SetUnwriteableMarginLeft(aUnwriteableMarginLeft); - SETUNWRITEABLEMARGIN - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom) -{ - nsPrintSettings::SetUnwriteableMarginBottom(aUnwriteableMarginBottom); - SETUNWRITEABLEMARGIN - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetUnwriteableMarginRight(double aUnwriteableMarginRight) -{ - nsPrintSettings::SetUnwriteableMarginRight(aUnwriteableMarginRight); - SETUNWRITEABLEMARGIN - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetPaperWidth(double* aPaperWidth) -{ - NS_ENSURE_ARG_POINTER(aPaperWidth); - QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit)); - *aPaperWidth = papersize.width(); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPaperWidth(double aPaperWidth) -{ - QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit)); - papersize.setWidth(aPaperWidth); - mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit)); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetPaperHeight(double* aPaperHeight) -{ - NS_ENSURE_ARG_POINTER(aPaperHeight); - QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit)); - *aPaperHeight = papersize.height(); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPaperHeight(double aPaperHeight) -{ - QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit)); - papersize.setHeight(aPaperHeight); - mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit)); - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::SetPaperSizeUnit(int16_t aPaperSizeUnit) -{ - mPaperSizeUnit = aPaperSizeUnit; - return NS_OK; -} - -NS_IMETHODIMP -nsPrintSettingsQt::GetEffectivePageSize(double* aWidth, double* aHeight) -{ - QSizeF papersize = mQPrinter->paperSize(QPrinter::Inch); - if (mQPrinter->orientation() == QPrinter::Landscape) { - *aWidth = NS_INCHES_TO_INT_TWIPS(papersize.height()); - *aHeight = NS_INCHES_TO_INT_TWIPS(papersize.width()); - } else { - *aWidth = NS_INCHES_TO_INT_TWIPS(papersize.width()); - *aHeight = NS_INCHES_TO_INT_TWIPS(papersize.height()); - } - return NS_OK; -} - diff --git a/widget/qt/nsPrintSettingsQt.h b/widget/qt/nsPrintSettingsQt.h deleted file mode 100644 index f9eb0f672009..000000000000 --- a/widget/qt/nsPrintSettingsQt.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsPrintSettingsQt_h_ -#define nsPrintSettingsQt_h_ - -#include -#include "nsPrintSettingsImpl.h" -#define NS_PRINTSETTINGSQT_IID \ -{0x5bc4c746, 0x8970, 0x43a3, {0xbf, 0xb1, 0x5d, 0xe1, 0x74, 0xaf, 0x7c, 0xea}} - -class QPrinter; -class nsPrintSettingsQt : public nsPrintSettings -{ -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSQT_IID) - - nsPrintSettingsQt(); - - NS_IMETHOD GetPrintRange(int16_t* aPrintRange); - NS_IMETHOD SetPrintRange(int16_t aPrintRange); - - NS_IMETHOD GetStartPageRange(int32_t* aStartPageRange); - NS_IMETHOD SetStartPageRange(int32_t aStartPageRange); - NS_IMETHOD GetEndPageRange(int32_t* aEndPageRange); - NS_IMETHOD SetEndPageRange(int32_t aEndPageRange); - - NS_IMETHOD GetPrintReversed(bool* aPrintReversed); - NS_IMETHOD SetPrintReversed(bool aPrintReversed); - - NS_IMETHOD GetPrintInColor(bool* aPrintInColor); - NS_IMETHOD SetPrintInColor(bool aPrintInColor); - - NS_IMETHOD GetOrientation(int32_t* aOrientation); - NS_IMETHOD SetOrientation(int32_t aOrientation); - - NS_IMETHOD GetToFileName(char16_t** aToFileName); - NS_IMETHOD SetToFileName(const char16_t* aToFileName); - - NS_IMETHOD GetPrinterName(char16_t** aPrinter); - NS_IMETHOD SetPrinterName(const char16_t* aPrinter); - - NS_IMETHOD GetNumCopies(int32_t* aNumCopies); - NS_IMETHOD SetNumCopies(int32_t aNumCopies); - - NS_IMETHOD GetScaling(double* aScaling); - NS_IMETHOD SetScaling(double aScaling); - - NS_IMETHOD GetPaperName(char16_t** aPaperName); - NS_IMETHOD SetPaperName(const char16_t* aPaperName); - - NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin); - NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop); - NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft); - NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom); - NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight); - - NS_IMETHOD GetPaperWidth(double* aPaperWidth); - NS_IMETHOD SetPaperWidth(double aPaperWidth); - - NS_IMETHOD GetPaperHeight(double* aPaperHeight); - NS_IMETHOD SetPaperHeight(double aPaperHeight); - - NS_IMETHOD SetPaperSizeUnit(int16_t aPaperSizeUnit); - - NS_IMETHOD GetEffectivePageSize(double* aWidth, double* aHeight); - -protected: - virtual ~nsPrintSettingsQt(); - - nsPrintSettingsQt(const nsPrintSettingsQt& src); - nsPrintSettingsQt& operator=(const nsPrintSettingsQt& rhs); - - virtual nsresult _Clone(nsIPrintSettings** _retval); - virtual nsresult _Assign(nsIPrintSettings* aPS); - - QSharedPointer mQPrinter; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsQt, NS_PRINTSETTINGSQT_IID) -#endif // nsPrintSettingsQt_h_ diff --git a/widget/qt/nsQtKeyUtils.cpp b/widget/qt/nsQtKeyUtils.cpp deleted file mode 100644 index 931075f5a12f..000000000000 --- a/widget/qt/nsQtKeyUtils.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include "mozilla/ArrayUtils.h" -#include "mozilla/TextEvents.h" - -#include "nsWindow.h" -#include "nsQtKeyUtils.h" - -using namespace mozilla; -using namespace mozilla::widget; - -struct nsKeyConverter -{ - int vkCode; // Platform independent key code - int keysym; // Qt key code -}; - -static struct nsKeyConverter nsKeycodes[] = -{ -// { NS_VK_CANCEL, Qt::Key_Cancel }, - { NS_VK_BACK, Qt::Key_Backspace }, - { NS_VK_TAB, Qt::Key_Tab }, - { NS_VK_TAB, Qt::Key_Backtab }, -// { NS_VK_CLEAR, Qt::Key_Clear }, - { NS_VK_RETURN, Qt::Key_Return }, - { NS_VK_RETURN, Qt::Key_Enter }, - { NS_VK_SHIFT, Qt::Key_Shift }, - { NS_VK_CONTROL, Qt::Key_Control }, - { NS_VK_ALT, Qt::Key_Alt }, - { NS_VK_PAUSE, Qt::Key_Pause }, - { NS_VK_CAPS_LOCK, Qt::Key_CapsLock }, - { NS_VK_ESCAPE, Qt::Key_Escape }, - { NS_VK_SPACE, Qt::Key_Space }, - { NS_VK_PAGE_UP, Qt::Key_PageUp }, - { NS_VK_PAGE_DOWN, Qt::Key_PageDown }, - { NS_VK_END, Qt::Key_End }, - { NS_VK_HOME, Qt::Key_Home }, - { NS_VK_LEFT, Qt::Key_Left }, - { NS_VK_UP, Qt::Key_Up }, - { NS_VK_RIGHT, Qt::Key_Right }, - { NS_VK_DOWN, Qt::Key_Down }, - { NS_VK_PRINTSCREEN, Qt::Key_Print }, - { NS_VK_INSERT, Qt::Key_Insert }, - { NS_VK_DELETE, Qt::Key_Delete }, - { NS_VK_HELP, Qt::Key_Help }, - - { NS_VK_0, Qt::Key_0 }, - { NS_VK_1, Qt::Key_1 }, - { NS_VK_2, Qt::Key_2 }, - { NS_VK_3, Qt::Key_3 }, - { NS_VK_4, Qt::Key_4 }, - { NS_VK_5, Qt::Key_5 }, - { NS_VK_6, Qt::Key_6 }, - { NS_VK_7, Qt::Key_7 }, - { NS_VK_8, Qt::Key_8 }, - { NS_VK_9, Qt::Key_9 }, - - { NS_VK_SEMICOLON, Qt::Key_Semicolon }, - { NS_VK_EQUALS, Qt::Key_Equal }, - - { NS_VK_A, Qt::Key_A }, - { NS_VK_B, Qt::Key_B }, - { NS_VK_C, Qt::Key_C }, - { NS_VK_D, Qt::Key_D }, - { NS_VK_E, Qt::Key_E }, - { NS_VK_F, Qt::Key_F }, - { NS_VK_G, Qt::Key_G }, - { NS_VK_H, Qt::Key_H }, - { NS_VK_I, Qt::Key_I }, - { NS_VK_J, Qt::Key_J }, - { NS_VK_K, Qt::Key_K }, - { NS_VK_L, Qt::Key_L }, - { NS_VK_M, Qt::Key_M }, - { NS_VK_N, Qt::Key_N }, - { NS_VK_O, Qt::Key_O }, - { NS_VK_P, Qt::Key_P }, - { NS_VK_Q, Qt::Key_Q }, - { NS_VK_R, Qt::Key_R }, - { NS_VK_S, Qt::Key_S }, - { NS_VK_T, Qt::Key_T }, - { NS_VK_U, Qt::Key_U }, - { NS_VK_V, Qt::Key_V }, - { NS_VK_W, Qt::Key_W }, - { NS_VK_X, Qt::Key_X }, - { NS_VK_Y, Qt::Key_Y }, - { NS_VK_Z, Qt::Key_Z }, - - { NS_VK_NUMPAD0, Qt::Key_0 }, - { NS_VK_NUMPAD1, Qt::Key_1 }, - { NS_VK_NUMPAD2, Qt::Key_2 }, - { NS_VK_NUMPAD3, Qt::Key_3 }, - { NS_VK_NUMPAD4, Qt::Key_4 }, - { NS_VK_NUMPAD5, Qt::Key_5 }, - { NS_VK_NUMPAD6, Qt::Key_6 }, - { NS_VK_NUMPAD7, Qt::Key_7 }, - { NS_VK_NUMPAD8, Qt::Key_8 }, - { NS_VK_NUMPAD9, Qt::Key_9 }, - { NS_VK_MULTIPLY, Qt::Key_Asterisk }, - { NS_VK_ADD, Qt::Key_Plus }, -// { NS_VK_SEPARATOR, Qt::Key_Separator }, - { NS_VK_SUBTRACT, Qt::Key_Minus }, - { NS_VK_DECIMAL, Qt::Key_Period }, - { NS_VK_DIVIDE, Qt::Key_Slash }, - { NS_VK_F1, Qt::Key_F1 }, - { NS_VK_F2, Qt::Key_F2 }, - { NS_VK_F3, Qt::Key_F3 }, - { NS_VK_F4, Qt::Key_F4 }, - { NS_VK_F5, Qt::Key_F5 }, - { NS_VK_F6, Qt::Key_F6 }, - { NS_VK_F7, Qt::Key_F7 }, - { NS_VK_F8, Qt::Key_F8 }, - { NS_VK_F9, Qt::Key_F9 }, - { NS_VK_F10, Qt::Key_F10 }, - { NS_VK_F11, Qt::Key_F11 }, - { NS_VK_F12, Qt::Key_F12 }, - { NS_VK_F13, Qt::Key_F13 }, - { NS_VK_F14, Qt::Key_F14 }, - { NS_VK_F15, Qt::Key_F15 }, - { NS_VK_F16, Qt::Key_F16 }, - { NS_VK_F17, Qt::Key_F17 }, - { NS_VK_F18, Qt::Key_F18 }, - { NS_VK_F19, Qt::Key_F19 }, - { NS_VK_F20, Qt::Key_F20 }, - { NS_VK_F21, Qt::Key_F21 }, - { NS_VK_F22, Qt::Key_F22 }, - { NS_VK_F23, Qt::Key_F23 }, - { NS_VK_F24, Qt::Key_F24 }, - - { NS_VK_NUM_LOCK, Qt::Key_NumLock }, - { NS_VK_SCROLL_LOCK, Qt::Key_ScrollLock }, - - { NS_VK_COMMA, Qt::Key_Comma }, - { NS_VK_PERIOD, Qt::Key_Period }, - { NS_VK_SLASH, Qt::Key_Slash }, - { NS_VK_BACK_QUOTE, Qt::Key_QuoteLeft }, - { NS_VK_OPEN_BRACKET, Qt::Key_ParenLeft }, - { NS_VK_CLOSE_BRACKET, Qt::Key_ParenRight }, - { NS_VK_QUOTE, Qt::Key_QuoteDbl }, - - { NS_VK_META, Qt::Key_Meta } -}; - -int -QtKeyCodeToDOMKeyCode(int aKeysym) -{ - unsigned int i; - - // First, try to handle alphanumeric input, not listed in nsKeycodes: - // most likely, more letters will be getting typed in than things in - // the key list, so we will look through these first. - - // since X has different key symbols for upper and lowercase letters and - // mozilla does not, convert gdk's to mozilla's - if (aKeysym >= Qt::Key_A && aKeysym <= Qt::Key_Z) - return aKeysym - Qt::Key_A + NS_VK_A; - - // numbers - if (aKeysym >= Qt::Key_0 && aKeysym <= Qt::Key_9) - return aKeysym - Qt::Key_0 + NS_VK_0; - - // keypad numbers -// if (aKeysym >= Qt::Key_KP_0 && aKeysym <= Qt::Key_KP_9) -// return aKeysym - Qt::Key_KP_0 + NS_VK_NUMPAD0; - - // misc other things - for (i = 0; i < ArrayLength(nsKeycodes); i++) { - if (nsKeycodes[i].keysym == aKeysym) - return(nsKeycodes[i].vkCode); - } - - // function keys - if (aKeysym >= Qt::Key_F1 && aKeysym <= Qt::Key_F24) - return aKeysym - Qt::Key_F1 + NS_VK_F1; - - return((int)0); -} - -int -DOMKeyCodeToQtKeyCode(int aKeysym) -{ - unsigned int i; - - // First, try to handle alphanumeric input, not listed in nsKeycodes: - // most likely, more letters will be getting typed in than things in - // the key list, so we will look through these first. - - if (aKeysym >= NS_VK_A && aKeysym <= NS_VK_Z) - // gdk and DOM both use the ASCII codes for these keys. - return aKeysym; - - // numbers - if (aKeysym >= NS_VK_0 && aKeysym <= NS_VK_9) - // gdk and DOM both use the ASCII codes for these keys. - return aKeysym - Qt::Key_0 + NS_VK_0; - - // keypad numbers - if (aKeysym >= NS_VK_NUMPAD0 && aKeysym <= NS_VK_NUMPAD9) { - NS_ERROR("keypad numbers conversion not implemented"); - //return aKeysym - NS_VK_NUMPAD0 + Qt::Key_KP_0; - return 0; - } - - // misc other things - for (i = 0; i < ArrayLength(nsKeycodes); ++i) { - if (nsKeycodes[i].vkCode == aKeysym) { - return nsKeycodes[i].keysym; - } - } - - // function keys - if (aKeysym >= NS_VK_F1 && aKeysym <= NS_VK_F9) - return aKeysym - NS_VK_F1 + Qt::Key_F1; - - return 0; -} - -KeyNameIndex -QtKeyCodeToDOMKeyNameIndex(int aKeysym) -{ - switch (aKeysym) { - -#define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex) \ - case aNativeKey: return aKeyNameIndex; - -#include "NativeKeyToDOMKeyName.h" - -#undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX - - case Qt::Key_Exclam: - case Qt::Key_QuoteDbl: - case Qt::Key_NumberSign: - case Qt::Key_Dollar: - case Qt::Key_Percent: - case Qt::Key_Ampersand: - case Qt::Key_Apostrophe: - case Qt::Key_ParenLeft: - case Qt::Key_ParenRight: - case Qt::Key_Asterisk: - case Qt::Key_Plus: - case Qt::Key_Comma: - case Qt::Key_Minus: - case Qt::Key_Period: - case Qt::Key_Slash: - case Qt::Key_0: - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: - case Qt::Key_Colon: - case Qt::Key_Semicolon: - case Qt::Key_Less: - case Qt::Key_Equal: - case Qt::Key_Greater: - case Qt::Key_Question: - case Qt::Key_At: - case Qt::Key_A: - case Qt::Key_B: - case Qt::Key_C: - case Qt::Key_D: - case Qt::Key_E: - case Qt::Key_F: - case Qt::Key_G: - case Qt::Key_H: - case Qt::Key_I: - case Qt::Key_J: - case Qt::Key_K: - case Qt::Key_L: - case Qt::Key_M: - case Qt::Key_N: - case Qt::Key_O: - case Qt::Key_P: - case Qt::Key_Q: - case Qt::Key_R: - case Qt::Key_S: - case Qt::Key_T: - case Qt::Key_U: - case Qt::Key_V: - case Qt::Key_W: - case Qt::Key_X: - case Qt::Key_Y: - case Qt::Key_Z: - case Qt::Key_BracketLeft: - case Qt::Key_Backslash: - case Qt::Key_BracketRight: - case Qt::Key_AsciiCircum: - case Qt::Key_Underscore: - case Qt::Key_QuoteLeft: - case Qt::Key_BraceLeft: - case Qt::Key_Bar: - case Qt::Key_BraceRight: - case Qt::Key_AsciiTilde: - case Qt::Key_exclamdown: - case Qt::Key_cent: - case Qt::Key_sterling: - case Qt::Key_currency: - case Qt::Key_yen: - case Qt::Key_brokenbar: - case Qt::Key_section: - case Qt::Key_diaeresis: - case Qt::Key_copyright: - case Qt::Key_ordfeminine: - case Qt::Key_guillemotleft: - case Qt::Key_notsign: - case Qt::Key_hyphen: - case Qt::Key_registered: - case Qt::Key_macron: - case Qt::Key_degree: - case Qt::Key_plusminus: - case Qt::Key_twosuperior: - case Qt::Key_threesuperior: - case Qt::Key_acute: - case Qt::Key_mu: - case Qt::Key_paragraph: - case Qt::Key_periodcentered: - case Qt::Key_cedilla: - case Qt::Key_onesuperior: - case Qt::Key_masculine: - case Qt::Key_guillemotright: - case Qt::Key_onequarter: - case Qt::Key_onehalf: - case Qt::Key_threequarters: - case Qt::Key_questiondown: - case Qt::Key_Agrave: - case Qt::Key_Aacute: - case Qt::Key_Acircumflex: - case Qt::Key_Atilde: - case Qt::Key_Adiaeresis: - case Qt::Key_Aring: - case Qt::Key_AE: - case Qt::Key_Ccedilla: - case Qt::Key_Egrave: - case Qt::Key_Eacute: - case Qt::Key_Ecircumflex: - case Qt::Key_Ediaeresis: - case Qt::Key_Igrave: - case Qt::Key_Iacute: - case Qt::Key_Icircumflex: - case Qt::Key_Idiaeresis: - case Qt::Key_ETH: - case Qt::Key_Ntilde: - case Qt::Key_Ograve: - case Qt::Key_Oacute: - case Qt::Key_Ocircumflex: - case Qt::Key_Otilde: - case Qt::Key_Odiaeresis: - case Qt::Key_multiply: - case Qt::Key_Ooblique: - case Qt::Key_Ugrave: - case Qt::Key_Uacute: - case Qt::Key_Ucircumflex: - case Qt::Key_Udiaeresis: - case Qt::Key_Yacute: - case Qt::Key_THORN: - case Qt::Key_ssharp: - case Qt::Key_division: - case Qt::Key_ydiaeresis: - return KEY_NAME_INDEX_PrintableKey; - - case Qt::Key_Backtab: - case Qt::Key_Direction_L: - case Qt::Key_Direction_R: - case Qt::Key_Touroku: - case Qt::Key_Massyo: - case Qt::Key_Hangul: - case Qt::Key_Hangul_Start: - case Qt::Key_Hangul_End: - case Qt::Key_Hangul_Hanja: - case Qt::Key_Hangul_Jamo: - case Qt::Key_Hangul_Romaja: - case Qt::Key_Hangul_Jeonja: - case Qt::Key_Hangul_Banja: - case Qt::Key_Hangul_PreHanja: - case Qt::Key_Hangul_PostHanja: - case Qt::Key_Hangul_Special: - case Qt::Key_TrebleUp: - case Qt::Key_TrebleDown: - case Qt::Key_OpenUrl: - case Qt::Key_KeyboardLightOnOff: - case Qt::Key_KeyboardBrightnessUp: - case Qt::Key_KeyboardBrightnessDown: - case Qt::Key_Memo: - case Qt::Key_LightBulb: - case Qt::Key_Shop: - case Qt::Key_History: - case Qt::Key_AddFavorite: - case Qt::Key_HotLinks: - case Qt::Key_Finance: - case Qt::Key_Community: - case Qt::Key_BackForward: - case Qt::Key_ApplicationLeft: - case Qt::Key_ApplicationRight: - case Qt::Key_Book: - case Qt::Key_ToDoList: - case Qt::Key_ClearGrab: - case Qt::Key_Display: - case Qt::Key_DOS: - case Qt::Key_Documents: - case Qt::Key_Game: - case Qt::Key_Go: - case Qt::Key_iTouch: - case Qt::Key_Market: - case Qt::Key_Meeting: - case Qt::Key_MenuKB: - case Qt::Key_MenuPB: - case Qt::Key_MySites: - case Qt::Key_News: - case Qt::Key_OfficeHome: - case Qt::Key_Option: - case Qt::Key_Phone: - case Qt::Key_RotateWindows: - case Qt::Key_RotationPB: - case Qt::Key_RotationKB: - case Qt::Key_SplitScreen: - case Qt::Key_Support: - case Qt::Key_TaskPane: - case Qt::Key_Terminal: - case Qt::Key_Tools: - case Qt::Key_Travel: - case Qt::Key_Xfer: - case Qt::Key_Away: - case Qt::Key_Messenger: - case Qt::Key_Pictures: - case Qt::Key_Battery: - case Qt::Key_Bluetooth: - case Qt::Key_WLAN: - case Qt::Key_UWB: - case Qt::Key_AudioRepeat: - case Qt::Key_AudioCycleTrack: - case Qt::Key_Time: - case Qt::Key_View: - case Qt::Key_TopMenu: - case Qt::Key_ContrastAdjust: - case Qt::Key_TouchpadToggle: - case Qt::Key_TouchpadOn: - case Qt::Key_TouchpadOff: - case Qt::Key_unknown: - case Qt::Key_Call: - case Qt::Key_Context1: - case Qt::Key_Context2: - case Qt::Key_Context3: - case Qt::Key_Context4: - case Qt::Key_Flip: - case Qt::Key_Hangup: - case Qt::Key_No: - case Qt::Key_Select: - case Qt::Key_Yes: - case Qt::Key_ToggleCallHangup: - case Qt::Key_VoiceDial: - case Qt::Key_LastNumberRedial: - default: - return KEY_NAME_INDEX_Unidentified; - } -} - -CodeNameIndex -ScanCodeToDOMCodeNameIndex(int32_t aScanCode) -{ - switch (aScanCode) { - -#define NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, aCodeNameIndex) \ - case aNativeKey: return aCodeNameIndex; - -#include "NativeKeyToDOMCodeName.h" - -#undef NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX - - default: - return CODE_NAME_INDEX_UNKNOWN; - } -} diff --git a/widget/qt/nsQtKeyUtils.h b/widget/qt/nsQtKeyUtils.h deleted file mode 100644 index 8fdeed975011..000000000000 --- a/widget/qt/nsQtKeyUtils.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __nsQtKeyUtils_h__ -#define __nsQtKeyUtils_h__ - -#include "mozilla/EventForwards.h" - -int QtKeyCodeToDOMKeyCode (int aKeysym); -int DOMKeyCodeToQtKeyCode (int aKeysym); - -mozilla::KeyNameIndex QtKeyCodeToDOMKeyNameIndex(int aKeysym); -mozilla::CodeNameIndex ScanCodeToDOMCodeNameIndex(int32_t aScanCode); - -#endif /* __nsQtKeyUtils_h__ */ diff --git a/widget/qt/nsScreenManagerQt.cpp b/widget/qt/nsScreenManagerQt.cpp deleted file mode 100644 index 732008028123..000000000000 --- a/widget/qt/nsScreenManagerQt.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include - -#include "nsScreenManagerQt.h" -#include "nsScreenQt.h" - -nsScreenManagerQt::nsScreenManagerQt() -{ - mInitialized = false; - desktop = 0; - screens = 0; -} - -nsScreenManagerQt::~nsScreenManagerQt() -{ - delete [] screens; -} - -// addref, release, QI -NS_IMPL_ISUPPORTS(nsScreenManagerQt, nsIScreenManager) - -void nsScreenManagerQt::init() -{ - if (mInitialized) - return; - - nScreens = QGuiApplication::screens().size(); - screens = new nsCOMPtr[nScreens]; - - for (int i = 0; i < nScreens; ++i) - screens[i] = new nsScreenQt(i); - mInitialized = true; -} - -// -// ScreenForRect -// -// Returns the screen that contains the rectangle. If the rect overlaps -// multiple screens, it picks the screen with the greatest area of intersection. -// -// The coordinates are in pixels (not twips) and in screen coordinates. -// -NS_IMETHODIMP -nsScreenManagerQt::ScreenForRect(int32_t inLeft, int32_t inTop, - int32_t inWidth, int32_t inHeight, - nsIScreen **outScreen) -{ - if (!mInitialized) - init(); - - QRect r(inLeft, inTop, inWidth, inHeight); - int best = 0; - int area = 0; - for (int i = 0; i < nScreens; ++i) { - const QRect& rect = QGuiApplication::screens()[i]->geometry(); - QRect intersection = r▭ - int a = intersection.width()*intersection.height(); - if (a > area) { - best = i; - area = a; - } - } - - NS_IF_ADDREF(*outScreen = screens[best]); - return NS_OK; -} - -NS_IMETHODIMP -nsScreenManagerQt::ScreenForId(uint32_t aId, nsIScreen** aOutScreen) -{ - if (!mInitialized) { - init(); - } - - if (aId < nScreens) { - NS_IF_ADDREF(*aOutScreen = screens[aId]); - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -// -// GetPrimaryScreen -// -// The screen with the menubar/taskbar. This shouldn't be needed very -// often. -// -NS_IMETHODIMP -nsScreenManagerQt::GetPrimaryScreen(nsIScreen **aPrimaryScreen) -{ - if (!desktop) - init(); - - NS_IF_ADDREF(*aPrimaryScreen = screens[0]); - return NS_OK; -} - -// -// GetNumberOfScreens -// -// Returns how many physical screens are available. -// -NS_IMETHODIMP -nsScreenManagerQt::GetNumberOfScreens(uint32_t *aNumberOfScreens) -{ - if (!desktop) - init(); - - *aNumberOfScreens = nScreens; - return NS_OK; -} - -NS_IMETHODIMP -nsScreenManagerQt::GetSystemDefaultScale(float *aDefaultScale) -{ - *aDefaultScale = 1.0f; - return NS_OK; -} - -NS_IMETHODIMP -nsScreenManagerQt::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen) -{ - // I don't know how to go from GtkWindow to nsIScreen, especially - // given xinerama and stuff, so let's just do this - QRect rect(0, 0, 1, 1); - return ScreenForRect(rect.x(), rect.y(), rect.width(), rect.height(), outScreen); -} diff --git a/widget/qt/nsScreenManagerQt.h b/widget/qt/nsScreenManagerQt.h deleted file mode 100644 index 0f5bb5f2a7ee..000000000000 --- a/widget/qt/nsScreenManagerQt.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsScreenManagerQt_h___ -#define nsScreenManagerQt_h___ - -#include "nsIScreenManager.h" -#include "nsIScreen.h" -#include "nsCOMPtr.h" - -//------------------------------------------------------------------------ -class QDesktopWidget; - -class nsScreenManagerQt : public nsIScreenManager -{ -public: - nsScreenManagerQt ( ); - - NS_DECL_ISUPPORTS - NS_DECL_NSISCREENMANAGER - -private: - virtual ~nsScreenManagerQt(); - void init (); - - nsCOMPtr *screens; - QDesktopWidget *desktop; - int nScreens; - bool mInitialized; -}; - -#endif // nsScreenManagerQt_h___ diff --git a/widget/qt/nsScreenQt.cpp b/widget/qt/nsScreenQt.cpp deleted file mode 100644 index 095238f24ad2..000000000000 --- a/widget/qt/nsScreenQt.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include -#include -#include -#include -#include - -#include "nsScreenQt.h" -#include "nsXULAppAPI.h" - -nsScreenQt::nsScreenQt(int aScreen) - : mScreen(aScreen) -{ - // nothing else to do. I guess we could cache a bunch of information - // here, but we want to ask the device at runtime in case anything - // has changed. -} - -nsScreenQt::~nsScreenQt() -{ -} - -NS_IMETHODIMP -nsScreenQt::GetId(uint32_t* aId) -{ - *aId = mScreen; - return NS_OK; -} - -NS_IMETHODIMP -nsScreenQt::GetRect(int32_t *outLeft,int32_t *outTop, - int32_t *outWidth,int32_t *outHeight) -{ - QRect r = QGuiApplication::screens()[mScreen]->geometry(); - - *outTop = r.x(); - *outLeft = r.y(); - *outWidth = r.width(); - *outHeight = r.height(); - - return NS_OK; -} - -NS_IMETHODIMP -nsScreenQt::GetAvailRect(int32_t *outLeft,int32_t *outTop, - int32_t *outWidth,int32_t *outHeight) -{ - QRect r = QGuiApplication::screens()[mScreen]->geometry(); - - *outTop = r.x(); - *outLeft = r.y(); - *outWidth = r.width(); - *outHeight = r.height(); - - return NS_OK; -} - -NS_IMETHODIMP -nsScreenQt::GetPixelDepth(int32_t *aPixelDepth) -{ - // ############# - *aPixelDepth = QGuiApplication::primaryScreen()->depth(); - return NS_OK; -} - -NS_IMETHODIMP -nsScreenQt::GetColorDepth(int32_t *aColorDepth) -{ - // ############### - return GetPixelDepth(aColorDepth); -} diff --git a/widget/qt/nsScreenQt.h b/widget/qt/nsScreenQt.h deleted file mode 100644 index ad3a0ef9af3b..000000000000 --- a/widget/qt/nsScreenQt.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsScreenQt_h___ -#define nsScreenQt_h___ - -#include "nsBaseScreen.h" - -//------------------------------------------------------------------------ - -class nsScreenQt : public nsBaseScreen -{ -public: - nsScreenQt (int aScreen); - virtual ~nsScreenQt(); - - NS_IMETHOD GetId(uint32_t* aId); - NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight); - NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight); - NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth); - NS_IMETHOD GetColorDepth(int32_t* aColorDepth); - -private: - int mScreen; -}; - -#endif // nsScreenQt_h___ diff --git a/widget/qt/nsWidgetFactory.cpp b/widget/qt/nsWidgetFactory.cpp deleted file mode 100644 index 87817a0b4a5f..000000000000 --- a/widget/qt/nsWidgetFactory.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright 2012 Mozilla Foundation and Mozilla contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "base/basictypes.h" - -#include "mozilla/ModuleUtils.h" -#include "mozilla/WidgetUtils.h" - -#include "nsCOMPtr.h" -#include "nsWidgetsCID.h" -#include "nsAppShell.h" - -#include "nsWindow.h" -#include "nsLookAndFeel.h" -#include "nsAppShellSingleton.h" -#include "nsScreenManagerQt.h" -#include "nsIdleServiceQt.h" -#include "nsTransferable.h" -#include "nsBidiKeyboard.h" - -#include "nsHTMLFormatConverter.h" -#include "nsXULAppAPI.h" - -#ifdef NS_PRINTING -#include "nsDeviceContextSpecQt.h" -#include "nsPrintSession.h" -#include "nsPrintOptionsQt.h" -#include "nsPrintDialogQt.h" -#endif - -#include "nsClipboard.h" -#include "nsClipboardHelper.h" - -#if defined(MOZ_X11) -#include "GfxInfoX11.h" -#else -#include "GfxInfo.h" -#endif - -using namespace mozilla::widget; - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerQt) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceQt, nsIdleServiceQt::GetInstance) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) -#ifdef NS_PRINTING -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQt) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsQt, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorQt) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceQt, Init) -#endif - -namespace mozilla { -namespace widget { -// This constructor should really be shared with all platforms. -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init) -} -} - - -NS_DEFINE_NAMED_CID(NS_APPSHELL_CID); -NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID); -NS_DEFINE_NAMED_CID(NS_WINDOW_CID); -NS_DEFINE_NAMED_CID(NS_CHILD_CID); -NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID); -NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); -NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); -NS_DEFINE_NAMED_CID(NS_GFXINFO_CID); -#ifdef NS_PRINTING -NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID); -NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID); -NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID); -NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID); -#endif - -static const mozilla::Module::CIDEntry kWidgetCIDs[] = { - { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor }, - { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor }, - { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor }, - { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor }, - { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor }, - { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, - { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceQtConstructor }, - { &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerQtConstructor }, - { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor }, - { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor }, - { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor }, -#ifdef NS_PRINTING - { &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecQtConstructor }, - { &kNS_PRINTDIALOGSERVICE_CID, false, nullptr, nsPrintDialogServiceQtConstructor }, - { &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorQtConstructor }, - { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor }, - { &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsQtConstructor }, -#endif - { nullptr } -}; - -static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { - { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID }, - { "@mozilla.org/widget/appshell/qt;1", &kNS_APPSHELL_CID }, - { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID }, - { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID }, - { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID }, - { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID }, - { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID }, - { "@mozilla.org/widgets/child_window/qt;1", &kNS_CHILD_CID }, - { "@mozilla.org/widgets/window/qt;1", &kNS_WINDOW_CID }, - { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID }, - { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID }, -#ifdef NS_PRINTING - { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID }, - { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID }, - { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID }, - { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID }, - { NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID }, -#endif - { nullptr } -}; - -static void -nsWidgetQtModuleDtor() -{ - // Shutdown all XP level widget classes. - WidgetUtils::Shutdown(); - - nsLookAndFeel::Shutdown(); - nsAppShellShutdown(); -} - -static const mozilla::Module kWidgetModule = { - mozilla::Module::kVersion, - kWidgetCIDs, - kWidgetContracts, - nullptr, - nullptr, - nsAppShellInit, - nsWidgetQtModuleDtor -}; - -NSMODULE_DEFN(nsWidgetQtModule) = &kWidgetModule; diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp deleted file mode 100644 index 49c392c5e116..000000000000 --- a/widget/qt/nsWindow.cpp +++ /dev/null @@ -1,2001 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ArrayUtils.h" -#include "mozilla/MiscEvents.h" -#include "mozilla/MouseEvents.h" -#include "mozilla/TextEvents.h" -#include "mozilla/TouchEvents.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef MOZ_X11 -#include -#include -#include "gfxXlibSurface.h" -#endif //MOZ_X11 - -#include "nsXULAppAPI.h" - -#include "prlink.h" - -#include "nsWindow.h" -#include "mozqwidget.h" - -#include "nsIdleService.h" -#include "nsIRollupListener.h" -#include "nsWidgetsCID.h" -#include "nsQtKeyUtils.h" -#include "mozilla/Services.h" -#include "mozilla/Preferences.h" -#include "mozilla/Likely.h" -#include "mozilla/layers/LayersTypes.h" -#include "nsIWidgetListener.h" -#include "ClientLayerManager.h" -#include "BasicLayers.h" - -#include "nsIStringBundle.h" -#include "nsGfxCIID.h" - -#include "imgIContainer.h" -#include "nsGfxCIID.h" -#include "nsIInterfaceRequestorUtils.h" - -#include "gfxQtPlatform.h" - -#include "nsIDOMWheelEvent.h" - -#include "GLContext.h" - -#ifdef MOZ_X11 -#include "keysym2ucs.h" -#endif - -#include "Layers.h" -#include "GLContextProvider.h" - -using namespace mozilla; -using namespace mozilla::gl; -using namespace mozilla::widget; -using namespace mozilla::gfx; -using namespace mozilla::layers; -using mozilla::gl::GLContext; - -#define kWindowPositionSlop 20 - -// Qt -static const int WHEEL_DELTA = 120; -static bool gGlobalsInitialized = false; -static bool sAltGrModifier = false; - -static void find_first_visible_parent(QWindow* aItem, QWindow*& aVisibleItem); -static bool is_mouse_in_window (MozQWidget* aWindow, double aMouseX, double aMouseY); - -NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget) - -nsWindow::nsWindow() -{ - LOG(("%s [%p]\n", __PRETTY_FUNCTION__, (void *)this)); - - mIsTopLevel = false; - mIsDestroyed = false; - mIsShown = false; - mEnabled = true; - mWidget = nullptr; - mVisible = false; - mActivatePending = false; - mWindowType = eWindowType_child; - mSizeState = nsSizeMode_Normal; - mLastSizeMode = nsSizeMode_Normal; - mQCursor = Qt::ArrowCursor; - mNeedsResize = false; - mNeedsMove = false; - mListenForResizes = false; - mNeedsShow = false; - mTimerStarted = false; - mMoveEvent.needDispatch = false; - - if (!gGlobalsInitialized) { - gfxPlatform::GetPlatform(); - gGlobalsInitialized = true; - } - - memset(mKeyDownFlags, 0, sizeof(mKeyDownFlags)); - - mIsTransparent = false; - - mCursor = eCursor_standard; -} - -nsWindow::~nsWindow() -{ - LOG(("%s [%p]\n", __PRETTY_FUNCTION__, (void *)this)); - - Destroy(); -} - -nsresult -nsWindow::Create(nsIWidget* aParent, - nsNativeWidget aNativeParent, - const LayoutDeviceIntRect& aRect, - nsWidgetInitData* aInitData) -{ - // only set the base parent if we're not going to be a dialog or a - // toplevel - nsIWidget *baseParent = aParent; - - // initialize all the common bits of this class - BaseCreate(baseParent, aInitData); - - mVisible = true; - - // and do our common creation - mParent = (nsWindow *)aParent; - - // save our bounds - mBounds = aRect; - - // find native parent - MozQWidget *parent = nullptr; - - if (aParent != nullptr) { - parent = static_cast(aParent->GetNativeData(NS_NATIVE_WIDGET)); - } else if (aNativeParent != nullptr) { - parent = static_cast(aNativeParent); - if (parent && mParent == nullptr) { - mParent = parent->getReceiver(); - } - } - - LOG(("Create: nsWindow [%p] mWidget:[%p] parent:[%p], natPar:[%p] mParent:%p\n", (void *)this, (void*)mWidget, parent, aNativeParent, mParent)); - - // ok, create our QGraphicsWidget - mWidget = createQWidget(parent, aInitData); - - if (!mWidget) { - return NS_ERROR_OUT_OF_MEMORY; - } - - - // resize so that everything is set to the right dimensions - Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, false); - - // check if we should listen for resizes - mListenForResizes = (aNativeParent || - (aInitData && aInitData->mListenForResizes)); - - return NS_OK; -} - -MozQWidget* -nsWindow::createQWidget(MozQWidget* parent, - nsWidgetInitData* aInitData) -{ - const char *windowName = nullptr; - Qt::WindowFlags flags = Qt::Widget; - - // ok, create our windows - switch (mWindowType) { - case eWindowType_dialog: - windowName = "topLevelDialog"; - flags = Qt::Dialog; - break; - case eWindowType_popup: - windowName = "topLevelPopup"; - flags = Qt::Popup; - break; - case eWindowType_toplevel: - windowName = "topLevelWindow"; - flags = Qt::Window; - break; - case eWindowType_invisible: - windowName = "topLevelInvisible"; - break; - case eWindowType_child: - case eWindowType_plugin: - default: // sheet - windowName = "paintArea"; - break; - } - - MozQWidget* widget = new MozQWidget(this, parent); - if (!widget) { - return nullptr; - } - - widget->setObjectName(QString(windowName)); - if (mWindowType == eWindowType_invisible) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) - widget->setVisibility(QWindow::Hidden); -#else - widget->hide(); -#endif - } - if (mWindowType == eWindowType_dialog) { - widget->setModality(Qt::WindowModal); - } - - widget->create(); - - // create a QGraphicsView if this is a new toplevel window - LOG(("nsWindow::%s [%p] Created Window: %s, widget:%p, par:%p\n", __FUNCTION__, (void *)this, windowName, widget, parent)); - - return widget; -} - -NS_IMETHODIMP -nsWindow::Destroy(void) -{ - if (mIsDestroyed || !mWidget) { - return NS_OK; - } - - LOG(("nsWindow::Destroy [%p]\n", (void *)this)); - mIsDestroyed = true; - - /** Need to clean our LayerManager up while still alive */ - if (mLayerManager) { - mLayerManager->Destroy(); - } - mLayerManager = nullptr; - - // It is safe to call DestroyeCompositor several times (here and - // in the parent class) since it will take effect only once. - // The reason we call it here is because on gtk platforms we need - // to destroy the compositor before we destroy the gdk window (which - // destroys the the gl context attached to it). - DestroyCompositor(); - - ClearCachedResources(); - - nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener(); - if (rollupListener) { - nsCOMPtr rollupWidget = rollupListener->GetRollupWidget(); - if (static_cast(this) == rollupWidget) { - rollupListener->Rollup(0, false, nullptr, nullptr); - } - } - - Show(false); - - // walk the list of children and call destroy on them. Have to be - // careful, though -- calling destroy on a kid may actually remove - // it from our child list, losing its sibling links. - for (nsIWidget* kid = mFirstChild; kid; ) { - nsIWidget* next = kid->GetNextSibling(); - kid->Destroy(); - kid = next; - } - - // Destroy thebes surface now. Badness can happen if we destroy - // the surface after its X Window. - if (mWidget) { - mWidget->dropReceiver(); - - // Call deleteLater instead of delete; Qt still needs the object - // to be valid even after sending it a Close event. We could - // also set WA_DeleteOnClose, but this gives us more control. - mWidget->deleteLater(); - } - mWidget = nullptr; - - OnDestroy(); - - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::Show(bool aState) -{ - LOG(("nsWindow::Show [%p] state %d\n", (void *)this, aState)); - if (aState == mIsShown) { - return NS_OK; - } - - // Clear our cached resources when the window is hidden. - if (mIsShown && !aState) { - ClearCachedResources(); - } - - mIsShown = aState; - - if ((aState && !AreBoundsSane()) || !mWidget) { - LOG(("\tbounds are insane or window hasn't been created yet\n")); - mNeedsShow = true; - return NS_OK; - } - - if (aState) { - if (mNeedsMove) { - NativeResize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, - false); - } else if (mNeedsResize) { - NativeResize(mBounds.width, mBounds.height, false); - } - } - else { - // If someone is hiding this widget, clear any needing show flag. - mNeedsShow = false; - } - - NativeShow(aState); - - return NS_OK; -} - -bool -nsWindow::IsVisible() const -{ - return mIsShown; -} - -NS_IMETHODIMP -nsWindow::ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY) -{ - if (!mWidget) { - return NS_ERROR_FAILURE; - } - - int32_t screenWidth = qApp->primaryScreen()->size().width(); - int32_t screenHeight = qApp->primaryScreen()->size().height(); - - if (aAllowSlop) { - if (*aX < (kWindowPositionSlop - mBounds.width)) - *aX = kWindowPositionSlop - mBounds.width; - if (*aX > (screenWidth - kWindowPositionSlop)) - *aX = screenWidth - kWindowPositionSlop; - if (*aY < (kWindowPositionSlop - mBounds.height)) - *aY = kWindowPositionSlop - mBounds.height; - if (*aY > (screenHeight - kWindowPositionSlop)) - *aY = screenHeight - kWindowPositionSlop; - } else { - if (*aX < 0) - *aX = 0; - if (*aX > (screenWidth - mBounds.width)) - *aX = screenWidth - mBounds.width; - if (*aY < 0) - *aY = 0; - if (*aY > (screenHeight - mBounds.height)) - *aY = screenHeight - mBounds.height; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::Move(double aX, double aY) -{ - LOG(("nsWindow::Move [%p] %f %f\n", (void *)this, - aX, aY)); - - int32_t x = NSToIntRound(aX); - int32_t y = NSToIntRound(aY); - - if (mIsTopLevel) { - SetSizeMode(nsSizeMode_Normal); - } - - if (x == mBounds.x && y == mBounds.y) { - return NS_OK; - } - - mNeedsMove = false; - - // update the bounds - QPoint pos(x, y); - if (mIsTopLevel) { - mWidget->setPosition(x, y); - } - else if (mWidget) { - // the position of the widget is set relative to the parent - // so we map the coordinates accordingly - pos = mWidget->mapToGlobal(pos); - mWidget->setPosition(pos); - } - - mBounds.x = pos.x(); - mBounds.y = pos.y(); - - NotifyRollupGeometryChange(); - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) -{ - mBounds.width = NSToIntRound(aWidth); - mBounds.height = NSToIntRound(aHeight); - - if (!mWidget) - return NS_OK; - - if (mIsShown) { - if (AreBoundsSane()) { - if (mIsTopLevel || mNeedsShow) - NativeResize(mBounds.x, mBounds.y, - mBounds.width, mBounds.height, aRepaint); - else - NativeResize(mBounds.width, mBounds.height, aRepaint); - - // Does it need to be shown because it was previously insane? - if (mNeedsShow) { - NativeShow(true); - } - } - else { - // If someone has set this so that the needs show flag is false - // and it needs to be hidden, update the flag and hide the - // window. This flag will be cleared the next time someone - // hides the window or shows it. It also prevents us from - // calling NativeShow(false) excessively on the window which - // causes unneeded X traffic. - if (!mNeedsShow) { - mNeedsShow = true; - NativeShow(false); - } - } - } - else if (AreBoundsSane() && mListenForResizes) { - // For widgets that we listen for resizes for (widgets created - // with native parents) we apparently _always_ have to resize. I - // dunno why, but apparently we're lame like that. - NativeResize(mBounds.width, mBounds.height, aRepaint); - } - else { - mNeedsResize = true; - } - - // synthesize a resize event if this isn't a toplevel - if (mIsTopLevel || mListenForResizes) { - nsEventStatus status; - DispatchResizeEvent(mBounds, status); - } - - NotifyRollupGeometryChange(); - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::Resize(double aX, double aY, double aWidth, double aHeight, - bool aRepaint) -{ - mBounds.x = NSToIntRound(aX); - mBounds.y = NSToIntRound(aY); - mBounds.width = NSToIntRound(aWidth); - mBounds.height = NSToIntRound(aHeight); - - mPlaced = true; - - if (!mWidget) { - return NS_OK; - } - - // Has this widget been set to visible? - if (mIsShown) { - // Are the bounds sane? - if (AreBoundsSane()) { - // Yep? Resize the window - NativeResize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, - aRepaint); - // Does it need to be shown because it was previously insane? - if (mNeedsShow) - NativeShow(true); - } - else { - // If someone has set this so that the needs show flag is false - // and it needs to be hidden, update the flag and hide the - // window. This flag will be cleared the next time someone - // hides the window or shows it. It also prevents us from - // calling NativeShow(false) excessively on the window which - // causes unneeded X traffic. - if (!mNeedsShow) { - mNeedsShow = true; - NativeShow(false); - } - } - } - // If the widget hasn't been shown, mark the widget as needing to be - // resized before it is shown - else if (AreBoundsSane() && mListenForResizes) { - // For widgets that we listen for resizes for (widgets created - // with native parents) we apparently _always_ have to resize. I - // dunno why, but apparently we're lame like that. - NativeResize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, - aRepaint); - } - else { - mNeedsResize = true; - mNeedsMove = true; - } - - if (mIsTopLevel || mListenForResizes) { - // synthesize a resize event - nsEventStatus status; - DispatchResizeEvent(mBounds, status); - } - - if (aRepaint) { - mWidget->renderLater(); - } - - NotifyRollupGeometryChange(); - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::Enable(bool aState) -{ - mEnabled = aState; - - return NS_OK; -} - -bool -nsWindow::IsEnabled() const -{ - return mEnabled; -} - -NS_IMETHODIMP -nsWindow::SetFocus(bool aRaise) -{ - // Make sure that our owning widget has focus. If it doesn't try to - // grab it. Note that we don't set our focus flag in this case. - LOGFOCUS((" SetFocus [%p]\n", (void *)this)); - - if (!mWidget) { - return NS_ERROR_FAILURE; - } - - if (mWidget->focusObject()) { - return NS_OK; - } - - // Because QGraphicsItem cannot get the focus if they are - // invisible, we look up the chain, for the lowest visible - // parent and focus that one - QWindow* realFocusItem = nullptr; - find_first_visible_parent(mWidget, realFocusItem); - - if (!realFocusItem || realFocusItem->focusObject()) { - return NS_OK; - } - - if (aRaise && mWidget) { - // the raising has to happen on the view widget - mWidget->raise(); - } - - // XXXndeakin why is this here? It should dispatch only when the OS - // notifies us. - DispatchActivateEvent(); - - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::ConfigureChildren(const nsTArray& aConfigurations) -{ - for (uint32_t i = 0; i < aConfigurations.Length(); ++i) { - const Configuration& configuration = aConfigurations[i]; - - nsWindow* w = static_cast(configuration.mChild.get()); - NS_ASSERTION(w->GetParent() == this, - "Configured widget is not a child"); - - if (w->mBounds.Size() != configuration.mBounds.Size()) { - w->Resize(configuration.mBounds.x, configuration.mBounds.y, - configuration.mBounds.width, configuration.mBounds.height, - true); - } else if (w->mBounds.TopLeft() != configuration.mBounds.TopLeft()) { - w->Move(configuration.mBounds.x, configuration.mBounds.y); - } - } - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::Invalidate(const LayoutDeviceIntRect& aRect) -{ - LOGDRAW(("Invalidate (rect) [%p,%p]: %d %d %d %d\n", (void *)this, - (void*)mWidget, aRect.x, aRect.y, aRect.width, aRect.height)); - - if (!mWidget) { - return NS_OK; - } - - mWidget->renderLater(); - - return NS_OK; -} - -LayoutDeviceIntPoint -nsWindow::WidgetToScreenOffset() -{ - NS_ENSURE_TRUE(mWidget, LayoutDeviceIntPoint(0,0)); - - QPoint origin(0, 0); - origin = mWidget->mapToGlobal(origin); - - return LayoutDeviceIntPoint(origin.x(), origin.y()); -} - -void* -nsWindow::GetNativeData(uint32_t aDataType) -{ - switch (aDataType) { - case NS_NATIVE_WINDOW: - case NS_NATIVE_WIDGET: { - return mWidget; - } - case NS_NATIVE_SHAREABLE_WINDOW: { - return mWidget ? (void*)mWidget->winId() : nullptr; - } - case NS_NATIVE_DISPLAY: { -#ifdef MOZ_X11 - return gfxQtPlatform::GetXDisplay(mWidget); -#endif - break; - } - case NS_NATIVE_PLUGIN_PORT: - case NS_NATIVE_GRAPHIC: - case NS_NATIVE_SHELLWIDGET: { - break; - } - case NS_RAW_NATIVE_IME_CONTEXT: { - void* pseudoIMEContext = GetPseudoIMEContext(); - if (pseudoIMEContext) { - return pseudoIMEContext; - } - // Our qt widget looks like using only one context per process. - // However, it's better to set the context's pointer. - return qApp->inputMethod(); - } - default: - NS_WARNING("nsWindow::GetNativeData called with bad value"); - return nullptr; - } - LOG(("nsWindow::%s [%p] aDataType:%i\n", __FUNCTION__, (void *)this, aDataType)); - return nullptr; -} - -NS_IMETHODIMP -nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus) -{ -#ifdef DEBUG - debug_DumpEvent(stdout, aEvent->mWidget, aEvent, - "something", 0); -#endif - - aStatus = nsEventStatus_eIgnore; - - // send it to the standard callback - if (mWidgetListener) { - aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents); - } - - return NS_OK; -} - -NS_IMETHODIMP_(void) -nsWindow::SetInputContext(const InputContext& aContext, - const InputContextAction& aAction) -{ - NS_ENSURE_TRUE_VOID(mWidget); - - // SetSoftwareKeyboardState uses mInputContext, - // so, before calling that, record aContext in mInputContext. - mInputContext = aContext; - - switch (mInputContext.mIMEState.mEnabled) { - case IMEState::ENABLED: - case IMEState::PASSWORD: - case IMEState::PLUGIN: - SetSoftwareKeyboardState(true, aAction); - break; - default: - SetSoftwareKeyboardState(false, aAction); - break; - } -} - -NS_IMETHODIMP_(InputContext) -nsWindow::GetInputContext() -{ - mInputContext.mIMEState.mOpen = IMEState::OPEN_STATE_NOT_SUPPORTED; - return mInputContext; -} - -NS_IMETHODIMP -nsWindow::ReparentNativeWidget(nsIWidget *aNewParent) -{ - NS_PRECONDITION(aNewParent, ""); - - MozQWidget* newParent = static_cast(aNewParent->GetNativeData(NS_NATIVE_WINDOW)); - NS_ASSERTION(newParent, "Parent widget has a null native window handle"); - if (mWidget) { - mWidget->setParent(newParent); - } - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen*) -{ - NS_ENSURE_TRUE(mWidget, NS_ERROR_FAILURE); - - if (aFullScreen) { - if (mSizeMode != nsSizeMode_Fullscreen) { - mLastSizeMode = mSizeMode; - } - - mSizeMode = nsSizeMode_Fullscreen; - mWidget->showFullScreen(); - } - else { - mSizeMode = mLastSizeMode; - - switch (mSizeMode) { - case nsSizeMode_Maximized: - mWidget->showMaximized(); - break; - case nsSizeMode_Minimized: - mWidget->showMinimized(); - break; - case nsSizeMode_Normal: - mWidget->showNormal(); - break; - default: - mWidget->showNormal(); - break; - } - } - - NS_ASSERTION(mLastSizeMode != nsSizeMode_Fullscreen, - "mLastSizeMode should never be fullscreen"); - return nsBaseWidget::MakeFullScreen(aFullScreen); -} - -LayerManager* -nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager, - LayersBackend aBackendHint, - LayerManagerPersistence aPersistence) -{ - if (!mLayerManager && eTransparencyTransparent == GetTransparencyMode()) { - mLayerManager = CreateBasicLayerManager(); - } - - return nsBaseWidget::GetLayerManager(aShadowManager, aBackendHint, - aPersistence); -} - -void -nsWindow::UserActivity() -{ - if (!mIdleService) { - mIdleService = do_GetService("@mozilla.org/widget/idleservice;1"); - } - - if (mIdleService) { - mIdleService->ResetIdleTimeOut(0); - } -} - -uint32_t -nsWindow::GetGLFrameBufferFormat() -{ - if (mLayerManager && - mLayerManager->GetBackendType() == mozilla::layers::LayersBackend::LAYERS_OPENGL) { - return LOCAL_GL_RGB; - } - return LOCAL_GL_NONE; -} - -already_AddRefed -nsWindow::StartRemoteDrawing() -{ - if (!mWidget) { - return nullptr; - } - -#ifdef MOZ_X11 - Display* dpy = gfxQtPlatform::GetXDisplay(mWidget); - Screen* screen = DefaultScreenOfDisplay(dpy); - Visual* defaultVisual = DefaultVisualOfScreen(screen); - gfxASurface* surf = new gfxXlibSurface(dpy, mWidget->winId(), defaultVisual, - IntSize(mWidget->width(), - mWidget->height())); - - IntSize size(surf->GetSize().width, surf->GetSize().height); - if (size.width <= 0 || size.height <= 0) { - return nullptr; - } - - return gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surf, size); -#else - return nullptr; -#endif -} - -NS_IMETHODIMP -nsWindow::SetCursor(nsCursor aCursor) -{ - if (mCursor == aCursor && !mUpdateCursor) { - return NS_OK; - } - mUpdateCursor = false; - mCursor = aCursor; - if (mWidget) { - mWidget->SetCursor(mCursor); - } - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::SetTitle(const nsAString& aTitle) -{ - QString qStr(QString::fromUtf16((const ushort*)aTitle.BeginReading(), aTitle.Length())); - - mWidget->setTitle(qStr); - - return NS_OK; -} - -// EVENTS - -nsIWidgetListener* -nsWindow::GetPaintListener() -{ - return mAttachedWidgetListener ? mAttachedWidgetListener : mWidgetListener; -} - -void -nsWindow::OnPaint() -{ - LOGDRAW(("nsWindow::%s [%p]\n", __FUNCTION__, (void *)this)); - nsIWidgetListener* listener = GetPaintListener(); - if (!listener) { - return; - } - - listener->WillPaintWindow(this); - - nsIWidgetListener* listener = GetPaintListener(); - if (!listener) { - return; - } - - switch (GetLayerManager()->GetBackendType()) { - case mozilla::layers::LayersBackend::LAYERS_CLIENT: { - LayoutDeviceIntRegion region( - LayoutDeviceIntRect(0, 0, mWidget->width(), mWidget->height())); - listener->PaintWindow(this, region); - break; - } - default: - NS_ERROR("Invalid layer manager"); - } - - nsIWidgetListener* listener = GetPaintListener(); - if (!listener) { - return; - } - - listener->DidPaintWindow(); -} - -nsEventStatus -nsWindow::moveEvent(QMoveEvent* aEvent) -{ - LOG(("configure event [%p] %d %d\n", (void *)this, - aEvent->pos().x(), aEvent->pos().y())); - - // can we shortcut? - if (!mWidget || !mWidgetListener) - return nsEventStatus_eIgnore; - - if ((mBounds.x == aEvent->pos().x() && - mBounds.y == aEvent->pos().y())) - { - return nsEventStatus_eIgnore; - } - - NotifyWindowMoved(aEvent->pos().x(), aEvent->pos().y()); - return nsEventStatus_eConsumeNoDefault; -} - -nsEventStatus -nsWindow::resizeEvent(QResizeEvent* aEvent) -{ - LayoutDeviceIntRect rect; - - // Generate XPFE resize event - GetBounds(rect); - - rect.width = aEvent->size().width(); - rect.height = aEvent->size().height(); - - mBounds.width = rect.width; - mBounds.height = rect.height; - - nsEventStatus status; - DispatchResizeEvent(rect, status); - return status; -} - -nsEventStatus -nsWindow::mouseMoveEvent(QMouseEvent* aEvent) -{ - UserActivity(); - - mMoveEvent.pos = aEvent->pos(); - mMoveEvent.modifiers = aEvent->modifiers(); - mMoveEvent.needDispatch = true; - DispatchMotionToMainThread(); - - return nsEventStatus_eIgnore; -} - -static void -InitMouseEvent(WidgetMouseEvent& aMouseEvent, QMouseEvent* aEvent, - int aClickCount) -{ - aMouseEvent.mRefPoint.x = nscoord(aEvent->pos().x()); - aMouseEvent.mRefPoint.y = nscoord(aEvent->pos().y()); - - aMouseEvent.InitBasicModifiers(aEvent->modifiers() & Qt::ControlModifier, - aEvent->modifiers() & Qt::AltModifier, - aEvent->modifiers() & Qt::ShiftModifier, - aEvent->modifiers() & Qt::MetaModifier); - aMouseEvent.mClickCount = aClickCount; - - switch (aEvent->button()) { - case Qt::LeftButton: - aMouseEvent.button = WidgetMouseEvent::eLeftButton; - break; - case Qt::RightButton: - aMouseEvent.button = WidgetMouseEvent::eRightButton; - break; - case Qt::MiddleButton: - aMouseEvent.button = WidgetMouseEvent::eMiddleButton; - break; - default: - break; - } -} - -static bool -IsAcceptedButton(Qt::MouseButton button) -{ - switch (button) { - case Qt::LeftButton: - case Qt::RightButton: - case Qt::MiddleButton: - return true; - default: - return false; - } -} - -nsEventStatus -nsWindow::mousePressEvent(QMouseEvent* aEvent) -{ - // The user has done something. - UserActivity(); - - QPoint pos = aEvent->pos(); - - // we check against the widgets geometry, so use parent coordinates - // for the check - if (mWidget) - pos = mWidget->mapToGlobal(pos); - - if (CheckForRollup(pos.x(), pos.y(), false)) - return nsEventStatus_eIgnore; - - if (!IsAcceptedButton(aEvent->button())) { - if (aEvent->button() == Qt::BackButton) - return DispatchCommandEvent(nsGkAtoms::Back); - if (aEvent->button() == Qt::ForwardButton) - return DispatchCommandEvent(nsGkAtoms::Forward); - return nsEventStatus_eIgnore; - } - - WidgetMouseEvent event(true, eMouseDown, this, WidgetMouseEvent::eReal); - InitMouseEvent(event, aEvent, 1); - nsEventStatus status = DispatchEvent(&event); - - // Right click on linux should also pop up a context menu. - if (event.button == WidgetMouseEvent::eRightButton && - MOZ_LIKELY(!mIsDestroyed)) { - WidgetMouseEvent contextMenuEvent(true, eContextMenu, this, - WidgetMouseEvent::eReal); - InitMouseEvent(contextMenuEvent, aEvent, 1); - DispatchEvent(&contextMenuEvent, status); - } - - return status; -} - -nsEventStatus -nsWindow::mouseReleaseEvent(QMouseEvent* aEvent) -{ - // The user has done something. - UserActivity(); - - if (!IsAcceptedButton(aEvent->button())) - return nsEventStatus_eIgnore; - - WidgetMouseEvent event(true, eMouseUp, this, WidgetMouseEvent::eReal); - InitMouseEvent(event, aEvent, 1); - return DispatchEvent(&event); -} - -nsEventStatus -nsWindow::mouseDoubleClickEvent(QMouseEvent* aEvent) -{ - // The user has done something. - UserActivity(); - - if (!IsAcceptedButton(aEvent->button())) - return nsEventStatus_eIgnore; - - WidgetMouseEvent event(true, eMouseDoubleClick, this, - WidgetMouseEvent::eReal); - InitMouseEvent(event, aEvent, 2); - return DispatchEvent(&event); -} - -nsEventStatus -nsWindow::focusInEvent(QFocusEvent* aEvent) -{ - LOGFOCUS(("OnFocusInEvent [%p]\n", (void *)this)); - - if (!mWidget) { - return nsEventStatus_eIgnore; - } - - DispatchActivateEventOnTopLevelWindow(); - - LOGFOCUS(("Events sent from focus in event [%p]\n", (void *)this)); - return nsEventStatus_eIgnore; -} - -nsEventStatus -nsWindow::focusOutEvent(QFocusEvent* aEvent) -{ - LOGFOCUS(("OnFocusOutEvent [%p]\n", (void *)this)); - - if (!mWidget) { - return nsEventStatus_eIgnore; - } - - DispatchDeactivateEventOnTopLevelWindow(); - - LOGFOCUS(("Done with container focus out [%p]\n", (void *)this)); - return nsEventStatus_eIgnore; -} - -static bool -IsContextMenuKeyEvent(const QKeyEvent* aQEvent) -{ - if (aQEvent->modifiers() & (Qt::ControlModifier | - Qt::AltModifier | - Qt::MetaModifier)) { - return false; - } - - bool isShift = aQEvent->modifiers() & Qt::ShiftModifier; - uint32_t keyCode = QtKeyCodeToDOMKeyCode(aQEvent->key()); - return (keyCode == NS_VK_F10 && isShift) || - (keyCode == NS_VK_CONTEXT_MENU && !isShift); -} - -static void -InitKeyEvent(WidgetKeyboardEvent& aEvent, QKeyEvent* aQEvent) -{ - aEvent.InitBasicModifiers(aQEvent->modifiers() & Qt::ControlModifier, - aQEvent->modifiers() & Qt::AltModifier, - aQEvent->modifiers() & Qt::ShiftModifier, - aQEvent->modifiers() & Qt::MetaModifier); - - aEvent.mIsRepeat = - (aEvent.mMessage == eKeyDown || aEvent.mMessage == eKeyPress) && - aQEvent->isAutoRepeat(); - aEvent.mTime = 0; - - if (sAltGrModifier) { - aEvent.mModifiers |= (MODIFIER_CONTROL | MODIFIER_ALT); - } - - if (aQEvent->text().length() && aQEvent->text()[0].isPrint()) { - aEvent.mCharCode = static_cast(aQEvent->text()[0].unicode()); - aEvent.mKeyCode = 0; - aEvent.mKeyNameIndex = KEY_NAME_INDEX_PrintableKey; - } else { - aEvent.mCharCode = 0; - aEvent.mKeyCode = QtKeyCodeToDOMKeyCode(aQEvent->key()); - aEvent.mKeyNameIndex = QtKeyCodeToDOMKeyNameIndex(aQEvent->key()); - } - - aEvent.mCodeNameIndex = ScanCodeToDOMCodeNameIndex(aQEvent->nativeScanCode()); - - // The transformations above and in qt for the keyval are not invertible - // so link to the QKeyEvent (which will vanish soon after return from the - // event callback) to give plugins access to hardware_keycode and state. - // (An XEvent would be nice but the QKeyEvent is good enough.) - aEvent.mPluginEvent.Copy(*aQEvent); -} - -nsEventStatus -nsWindow::keyPressEvent(QKeyEvent* aEvent) -{ - LOGFOCUS(("OnKeyPressEvent [%p]\n", (void *)this)); - - // The user has done something. - UserActivity(); - - if (aEvent->key() == Qt::Key_AltGr) { - sAltGrModifier = true; - } - - // Before we dispatch a key, check if it's the context menu key. - // If so, send a context menu key event instead. - if (IsContextMenuKeyEvent(aEvent)) { - WidgetMouseEvent contextMenuEvent(true, eContextMenu, this, - WidgetMouseEvent::eReal, - WidgetMouseEvent::eContextMenuKey); - return DispatchEvent(&contextMenuEvent); - } - - //:TODO: fix shortcuts hebrew for non X11, - //see Bug 562195##51 - - uint32_t domKeyCode = QtKeyCodeToDOMKeyCode(aEvent->key()); - - if (!aEvent->isAutoRepeat() && !IsKeyDown(domKeyCode)) { - SetKeyDownFlag(domKeyCode); - - WidgetKeyboardEvent downEvent(true, eKeyDown, this); - InitKeyEvent(downEvent, aEvent); - - nsEventStatus status = DispatchEvent(&downEvent); - - // DispatchEvent can Destroy us (bug 378273) - if (MOZ_UNLIKELY(mIsDestroyed)) { - qWarning() << "Returning[" << __LINE__ << "]: " << "Window destroyed"; - return status; - } - - // If prevent default on keydown, don't dispatch keypress event - if (status == nsEventStatus_eConsumeNoDefault) { - return nsEventStatus_eConsumeNoDefault; - } - } - - // Don't pass modifiers as eKeyPress events. - // Instead of selectively excluding some keys from eKeyPress events, - // we instead selectively include (as per MSDN spec - // ( http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keypress%28VS.71%29.aspx ); - // no official spec covers KeyPress events). - if (aEvent->key() == Qt::Key_Shift || - aEvent->key() == Qt::Key_Control || - aEvent->key() == Qt::Key_Meta || - aEvent->key() == Qt::Key_Alt || - aEvent->key() == Qt::Key_AltGr) { - return nsEventStatus_eIgnore; - } - - // Look for specialized app-command keys - switch (aEvent->key()) { - case Qt::Key_Back: - return DispatchCommandEvent(nsGkAtoms::Back); - case Qt::Key_Forward: - return DispatchCommandEvent(nsGkAtoms::Forward); - case Qt::Key_Refresh: - return DispatchCommandEvent(nsGkAtoms::Reload); - case Qt::Key_Stop: - return DispatchCommandEvent(nsGkAtoms::Stop); - case Qt::Key_Search: - return DispatchCommandEvent(nsGkAtoms::Search); - case Qt::Key_Favorites: - return DispatchCommandEvent(nsGkAtoms::Bookmarks); - case Qt::Key_HomePage: - return DispatchCommandEvent(nsGkAtoms::Home); - case Qt::Key_Copy: - case Qt::Key_F16: // F16, F20, F18, F14 are old keysyms for Copy Cut Paste Undo - return DispatchContentCommandEvent(eContentCommandCopy); - case Qt::Key_Cut: - case Qt::Key_F20: - return DispatchContentCommandEvent(eContentCommandCut); - case Qt::Key_Paste: - case Qt::Key_F18: - case Qt::Key_F9: - return DispatchContentCommandEvent(eContentCommandPaste); - case Qt::Key_F14: - return DispatchContentCommandEvent(eContentCommandUndo); - } - - // Qt::Key_Redo and Qt::Key_Undo are not available yet. - if (aEvent->nativeVirtualKey() == 0xff66) { - return DispatchContentCommandEvent(eContentCommandRedo); - } - if (aEvent->nativeVirtualKey() == 0xff65) { - return DispatchContentCommandEvent(eContentCommandUndo); - } - - WidgetKeyboardEvent event(true, eKeyPress, this); - InitKeyEvent(event, aEvent); - // Seend the key press event - return DispatchEvent(&event); -} - -nsEventStatus -nsWindow::keyReleaseEvent(QKeyEvent* aEvent) -{ - LOGFOCUS(("OnKeyReleaseEvent [%p]\n", (void *)this)); - - // The user has done something. - UserActivity(); - - if (IsContextMenuKeyEvent(aEvent)) { - // er, what do we do here? DoDefault or NoDefault? - return nsEventStatus_eConsumeDoDefault; - } - - // send the key event as a key up event - WidgetKeyboardEvent event(true, eKeyUp, this); - InitKeyEvent(event, aEvent); - - if (aEvent->key() == Qt::Key_AltGr) { - sAltGrModifier = false; - } - - // unset the key down flag - ClearKeyDownFlag(event.keyCode); - - return DispatchEvent(&event); -} - -nsEventStatus -nsWindow::wheelEvent(QWheelEvent* aEvent) -{ - // check to see if we should rollup - WidgetWheelEvent wheelEvent(true, eWheel, this); - wheelEvent.mDeltaMode = nsIDOMWheelEvent::DOM_DELTA_LINE; - - // negative values for aEvent->delta indicate downward scrolling; - // this is opposite Gecko usage. - // TODO: Store the unused delta values due to fraction round and add it - // to next event. The stored values should be reset by other - // direction scroll event. - int32_t delta = (int)(aEvent->delta() / WHEEL_DELTA) * -3; - - switch (aEvent->orientation()) { - case Qt::Vertical: - wheelEvent.mDeltaY = wheelEvent.mLineOrPageDeltaY = delta; - break; - case Qt::Horizontal: - wheelEvent.mDeltaX = wheelEvent.mLineOrPageDeltaX = delta; - break; - default: - Q_ASSERT(0); - break; - } - - wheelEvent.mRefPoint.x = nscoord(aEvent->pos().x()); - wheelEvent.mRefPoint.y = nscoord(aEvent->pos().y()); - - wheelEvent.InitBasicModifiers(aEvent->modifiers() & Qt::ControlModifier, - aEvent->modifiers() & Qt::AltModifier, - aEvent->modifiers() & Qt::ShiftModifier, - aEvent->modifiers() & Qt::MetaModifier); - wheelEvent.mTime = 0; - - return DispatchEvent(&wheelEvent); -} - -nsEventStatus -nsWindow::showEvent(QShowEvent *) -{ - LOG(("%s [%p]\n", __PRETTY_FUNCTION__,(void *)this)); - mVisible = true; - return nsEventStatus_eConsumeDoDefault; -} - -nsEventStatus -nsWindow::hideEvent(QHideEvent *) -{ - LOG(("%s [%p]\n", __PRETTY_FUNCTION__,(void *)this)); - mVisible = false; - return nsEventStatus_eConsumeDoDefault; -} - -nsEventStatus nsWindow::touchEvent(QTouchEvent* aEvent) -{ - return nsEventStatus_eIgnore; -} - -nsEventStatus -nsWindow::tabletEvent(QTabletEvent* aEvent) -{ - LOGFOCUS(("nsWindow::%s [%p]\n", __FUNCTION__, (void *)this)); - return nsEventStatus_eIgnore; -} - -// Helpers - -nsEventStatus -nsWindow::DispatchEvent(WidgetGUIEvent* aEvent) -{ - nsEventStatus status; - DispatchEvent(aEvent, status); - return status; -} - -void -nsWindow::DispatchActivateEvent(void) -{ - if (mWidgetListener) { - mWidgetListener->WindowActivated(); - } -} - -void -nsWindow::DispatchDeactivateEvent(void) -{ - if (mWidgetListener) { - mWidgetListener->WindowDeactivated(); - } -} - -void -nsWindow::DispatchActivateEventOnTopLevelWindow(void) -{ - nsWindow* topLevelWindow = static_cast(GetTopLevelWidget()); - if (topLevelWindow != nullptr) { - topLevelWindow->DispatchActivateEvent(); - } -} - -void -nsWindow::DispatchDeactivateEventOnTopLevelWindow(void) -{ - nsWindow* topLevelWindow = static_cast(GetTopLevelWidget()); - if (topLevelWindow != nullptr) { - topLevelWindow->DispatchDeactivateEvent(); - } -} - -void -nsWindow::DispatchResizeEvent(LayoutDeviceIntRect& aRect, - nsEventStatus& aStatus) -{ - aStatus = nsEventStatus_eIgnore; - if (mWidgetListener && - mWidgetListener->WindowResized(this, aRect.width, aRect.height)) { - aStatus = nsEventStatus_eConsumeNoDefault; - } -} - -///////////////////////////////////// OLD GECKO ECENTS need to Sort /////////////////// - -void -nsWindow::ClearCachedResources() -{ - if (mLayerManager && - mLayerManager->GetBackendType() == mozilla::layers::LayersBackend::LAYERS_BASIC) { - mLayerManager->ClearCachedResources(); - } - for (nsIWidget* kid = mFirstChild; kid; ) { - nsIWidget* next = kid->GetNextSibling(); - static_cast(kid)->ClearCachedResources(); - kid = next; - } -} - -NS_IMETHODIMP -nsWindow::SetParent(nsIWidget *aNewParent) -{ - NS_ENSURE_ARG_POINTER(aNewParent); - - nsCOMPtr kungFuDeathGrip(this); - nsIWidget* parent = GetParent(); - if (parent) { - parent->RemoveChild(this); - } - ReparentNativeWidget(aNewParent); - aNewParent->AddChild(this); - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::SetModal(bool aModal) -{ - LOG(("nsWindow::SetModal [%p] %d, widget[%p]\n", (void *)this, aModal, mWidget)); - if (mWidget) { - mWidget->setModality(aModal ? Qt::WindowModal : Qt::NonModal); - } - - return NS_OK; -} - - -NS_IMETHODIMP -nsWindow::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, - nsIWidget *aWidget, - bool aActivate) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsWindow::SetSizeMode(nsSizeMode aMode) -{ - nsresult rv; - - LOG(("nsWindow::SetSizeMode [%p] %d\n", (void *)this, aMode)); - if (aMode != nsSizeMode_Minimized) { - mWidget->requestActivate(); - } - - // Save the requested state. - rv = nsBaseWidget::SetSizeMode(aMode); - - // return if there's no shell or our current state is the same as - // the mode we were just set to. - if (!mWidget || mSizeState == mSizeMode) { - return rv; - } - - switch (aMode) { - case nsSizeMode_Maximized: - mWidget->showMaximized(); - break; - case nsSizeMode_Minimized: - mWidget->showMinimized(); - break; - case nsSizeMode_Fullscreen: - mWidget->showFullScreen(); - break; - - default: - // nsSizeMode_Normal, really. - mWidget->show(); - break; - } - - mSizeState = mSizeMode; - - return rv; -} - -// Helper function to recursively find the first parent item that -// is still visible (QGraphicsItem can be hidden even if they are -// set to visible if one of their ancestors is invisible) -/* static */ -void find_first_visible_parent(QWindow* aItem, QWindow*& aVisibleItem) -{ - NS_ENSURE_TRUE_VOID(aItem); - - aVisibleItem = nullptr; - QWindow* parItem = nullptr; - while (!aVisibleItem) { - if (aItem->isVisible()) { - aVisibleItem = aItem; - } - else { - parItem = aItem->parent(); - if (parItem) { - aItem = parItem; - } - else { - aItem->setVisible(true); - aVisibleItem = aItem; - } - } - } -} - -NS_IMETHODIMP -nsWindow::GetScreenBounds(LayoutDeviceIntRect& aRect) -{ - aRect = LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0), mBounds.Size()); - if (mIsTopLevel) { - QPoint pos = mWidget->position(); - aRect.MoveTo(pos.x(), pos.y()); - } else { - aRect.MoveTo(WidgetToScreenOffset()); - } - LOG(("GetScreenBounds %d %d | %d %d | %d %d\n", - aRect.x, aRect.y, - mBounds.width, mBounds.height, - aRect.width, aRect.height)); - return NS_OK; -} - -NS_IMETHODIMP -nsWindow::SetIcon(const nsAString& aIconSpec) -{ - if (!mWidget) - return NS_OK; - - nsCOMPtr iconFile; - nsAutoCString path; - nsTArray iconList; - - // Look for icons with the following suffixes appended to the base name. - // The last two entries (for the old XPM format) will be ignored unless - // no icons are found using the other suffixes. XPM icons are depricated. - - const char extensions[6][7] = { ".png", "16.png", "32.png", "48.png", - ".xpm", "16.xpm" }; - - for (uint32_t i = 0; i < ArrayLength(extensions); i++) { - // Don't bother looking for XPM versions if we found a PNG. - if (i == ArrayLength(extensions) - 2 && iconList.Length()) - break; - - nsAutoString extension; - extension.AppendASCII(extensions[i]); - - ResolveIconName(aIconSpec, extension, getter_AddRefs(iconFile)); - if (iconFile) { - iconFile->GetNativePath(path); - iconList.AppendElement(path); - } - } - - // leave the default icon intact if no matching icons were found - if (iconList.Length() == 0) - return NS_OK; - - return SetWindowIconList(iconList); -} - -NS_IMETHODIMP -nsWindow::CaptureMouse(bool aCapture) -{ - LOG(("CaptureMouse %p\n", (void *)this)); - - if (!mWidget) - return NS_OK; - - mWidget->setMouseGrabEnabled(aCapture); - - return NS_OK; -} - -bool -nsWindow::CheckForRollup(double aMouseX, double aMouseY, - bool aIsWheel) -{ - nsIRollupListener* rollupListener = GetActiveRollupListener(); - nsCOMPtr rollupWidget; - if (rollupListener) { - rollupWidget = rollupListener->GetRollupWidget(); - } - if (!rollupWidget) { - nsBaseWidget::gRollupListener = nullptr; - return false; - } - - bool retVal = false; - MozQWidget *currentPopup = - (MozQWidget *)rollupWidget->GetNativeData(NS_NATIVE_WINDOW); - if (!is_mouse_in_window(currentPopup, aMouseX, aMouseY)) { - bool rollup = true; - if (aIsWheel) { - rollup = rollupListener->ShouldRollupOnMouseWheelEvent(); - retVal = true; - } - // if we're dealing with menus, we probably have submenus and - // we don't want to rollup if the clickis in a parent menu of - // the current submenu - uint32_t popupsToRollup = UINT32_MAX; - if (rollupListener) { - AutoTArray widgetChain; - uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain); - for (uint32_t i=0; iGetNativeData(NS_NATIVE_WINDOW); - if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) { - if (i < sameTypeCount) { - rollup = false; - } - else { - popupsToRollup = sameTypeCount; - } - break; - } - } // foreach parent menu widget - } // if rollup listener knows about menus - - // if we've determined that we should still rollup, do it. - if (rollup) { - nsIntPoint pos(aMouseX, aMouseY); - retVal = rollupListener->Rollup(popupsToRollup, true, &pos, nullptr); - } - } - - return retVal; -} - -/* static */ -bool -is_mouse_in_window (MozQWidget* aWindow, double aMouseX, double aMouseY) -{ - return aWindow->geometry().contains(aMouseX, aMouseY); -} - -NS_IMETHODIMP -nsWindow::GetAttention(int32_t aCycleCount) -{ - LOG(("nsWindow::GetAttention [%p]\n", (void *)this)); - return NS_ERROR_NOT_IMPLEMENTED; -} - - - -nsEventStatus -nsWindow::OnCloseEvent(QCloseEvent *aEvent) -{ - if (!mWidgetListener) - return nsEventStatus_eIgnore; - mWidgetListener->RequestWindowClose(this); - return nsEventStatus_eConsumeNoDefault; -} - - -inline bool -is_latin_shortcut_key(quint32 aKeyval) -{ - return ((Qt::Key_0 <= aKeyval && aKeyval <= Qt::Key_9) || - (Qt::Key_A <= aKeyval && aKeyval <= Qt::Key_Z)); -} - -nsEventStatus -nsWindow::DispatchCommandEvent(nsIAtom* aCommand) -{ - WidgetCommandEvent event(true, nsGkAtoms::onAppCommand, aCommand, this); - - nsEventStatus status; - DispatchEvent(&event, status); - - return status; -} - -nsEventStatus -nsWindow::DispatchContentCommandEvent(EventMessage aMsg) -{ - WidgetContentCommandEvent event(true, aMsg, this); - - nsEventStatus status; - DispatchEvent(&event, status); - - return status; -} - - -static void -GetBrandName(nsXPIDLString& brandName) -{ - nsCOMPtr bundleService = - mozilla::services::GetStringBundleService(); - - nsCOMPtr bundle; - if (bundleService) { - bundleService->CreateBundle( - "chrome://branding/locale/brand.properties", - getter_AddRefs(bundle)); - } - - if (bundle) { - bundle->GetStringFromName( - MOZ_UTF16("brandShortName"), - getter_Copies(brandName)); - } - - if (brandName.IsEmpty()) { - brandName.AssignLiteral(MOZ_UTF16("Mozilla")); - } -} - -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 = nullptr; - class_hint->res_name = ToNewCString(xulWinType); - if (!class_hint->res_name) { - XFree(class_hint); - return NS_ERROR_OUT_OF_MEMORY; - } - class_hint->res_class = ToNewCString(brandName); - if (!class_hint->res_class) { - free(class_hint->res_name); - XFree(class_hint); - return NS_ERROR_OUT_OF_MEMORY; - } - - // Parse res_name into a name and role. Characters other than - // [A-Za-z0-9_-] are converted to '_'. Anything after the first - // colon is assigned to role; if there's no colon, assign the - // whole thing to both role and res_name. - for (char *c = class_hint->res_name; *c; c++) { - if (':' == *c) { - *c = 0; - role = c + 1; - } - else if (!isascii(*c) || (!isalnum(*c) && ('_' != *c) && ('-' != *c))) - *c = '_'; - } - class_hint->res_name[0] = toupper(class_hint->res_name[0]); - if (!role) role = class_hint->res_name; - - QWindow *widget = mWidget; - // If widget not show, handle might be null - if (widget && widget->winId()) { - XSetClassHint(gfxQtPlatform::GetXDisplay(widget), - widget->winId(), - class_hint); - } - - free(class_hint->res_class); - free(class_hint->res_name); - XFree(class_hint); -#endif - - return NS_OK; -} - -void -nsWindow::NativeResize(int32_t aWidth, int32_t aHeight, bool aRepaint) -{ - LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this, - aWidth, aHeight)); - - mNeedsResize = false; - - mWidget->resize(aWidth, aHeight); - - if (aRepaint) { - mWidget->renderLater(); - } -} - -void -nsWindow::NativeResize(int32_t aX, int32_t aY, - int32_t aWidth, int32_t aHeight, - bool aRepaint) -{ - LOG(("nsWindow::NativeResize [%p] %d %d %d %d\n", (void *)this, - aX, aY, aWidth, aHeight)); - - mNeedsResize = false; - mNeedsMove = false; - - mWidget->setGeometry(aX, aY, aWidth, aHeight); - - if (aRepaint) { - mWidget->renderLater(); - } -} - -void -nsWindow::NativeShow(bool aAction) -{ - if (aAction) { - // On e10s, we never want the child process or plugin process - // to go fullscreen because if we do the window because visible - // do to disabled Qt-Xembed - mWidget->show(); - // unset our flag now that our window has been shown - mNeedsShow = false; - } - else { - mWidget->hide(); - } -} - -NS_IMETHODIMP -nsWindow::SetHasTransparentBackground(bool aTransparent) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -nsWindow::GetHasTransparentBackground(bool& aTransparent) -{ - aTransparent = mIsTransparent; - return NS_OK; -} - -void * -nsWindow::SetupPluginPort(void) -{ - NS_WARNING("Not implemented"); - return nullptr; -} - -nsresult -nsWindow::SetWindowIconList(const nsTArray &aIconList) -{ - QIcon icon; - - for (uint32_t i = 0; i < aIconList.Length(); ++i) { - const char *path = aIconList[i].get(); - LOG(("window [%p] Loading icon from %s\n", (void *)this, path)); - icon.addFile(path); - } - - mWidget->setIcon(icon); - - return NS_OK; -} - -void -nsWindow::SetDefaultIcon(void) -{ - SetIcon(NS_LITERAL_STRING("default")); -} - -void nsWindow::QWidgetDestroyed() -{ - mWidget = nullptr; -} - - -NS_IMETHODIMP -nsWindow::HideWindowChrome(bool aShouldHide) -{ - if (!mWidget) { - // Nothing to hide - return NS_ERROR_FAILURE; - } - - // Sawfish, metacity, and presumably other window managers get - // confused if we change the window decorations while the window - // is visible. - bool wasVisible = false; - if (mWidget->isVisible()) { - NativeShow(false); - wasVisible = true; - } - - if (wasVisible) { - NativeShow(true); - } - - return NS_OK; -} - -////////////////////////////////////////////////////////////////////// - -NS_IMETHODIMP_(bool) -nsWindow::HasGLContext() -{ - return false; -} - - -nsIWidget* -nsWindow::GetParent(void) -{ - return mParent; -} - -float -nsWindow::GetDPI() -{ - return qApp->primaryScreen()->logicalDotsPerInch(); -} - -void -nsWindow::OnDestroy(void) -{ - if (mOnDestroyCalled) { - return; - } - - mOnDestroyCalled = true; - - // release references to children and device context - nsBaseWidget::OnDestroy(); - - // let go of our parent - mParent = nullptr; - - nsCOMPtr kungFuDeathGrip = this; - NotifyWindowDestroyed(); -} - -bool -nsWindow::AreBoundsSane(void) -{ - if (mBounds.width > 0 && mBounds.height > 0) { - return true; - } - - return false; -} - -void -nsWindow::SetSoftwareKeyboardState(bool aOpen, - const InputContextAction& aAction) -{ - if (aOpen) { - NS_ENSURE_TRUE_VOID(mInputContext.mIMEState.mEnabled != - IMEState::DISABLED); - - // Ensure that opening the virtual keyboard is allowed for this specific - // InputContext depending on the content.ime.strict.policy pref - if (mInputContext.mIMEState.mEnabled != IMEState::PLUGIN && - Preferences::GetBool("content.ime.strict_policy", false) && - !aAction.ContentGotFocusByTrustedCause() && - !aAction.UserMightRequestOpenVKB()) { - return; - } - } - - if (aOpen) { - qApp->inputMethod()->show(); - } else { - qApp->inputMethod()->hide(); - } - - return; -} - - -void -nsWindow::ProcessMotionEvent() -{ - if (mMoveEvent.needDispatch) { - WidgetMouseEvent event(true, eMouseMove, this, WidgetMouseEvent::eReal); - - event.mRefPoint.x = nscoord(mMoveEvent.pos.x()); - event.mRefPoint.y = nscoord(mMoveEvent.pos.y()); - - event.InitBasicModifiers(mMoveEvent.modifiers & Qt::ControlModifier, - mMoveEvent.modifiers & Qt::AltModifier, - mMoveEvent.modifiers & Qt::ShiftModifier, - mMoveEvent.modifiers & Qt::MetaModifier); - event.mClickCount = 0; - - DispatchEvent(&event); - mMoveEvent.needDispatch = false; - } - - mTimerStarted = false; -} - diff --git a/widget/qt/nsWindow.h b/widget/qt/nsWindow.h deleted file mode 100644 index 95ffaa2e6f3e..000000000000 --- a/widget/qt/nsWindow.h +++ /dev/null @@ -1,331 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim:expandtab:shiftwidth=4:tabstop=4: - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __nsWindow_h__ -#define __nsWindow_h__ - -#include - -#include "nsBaseWidget.h" -#include "mozilla/EventForwards.h" - -#include "nsGkAtoms.h" -#include "nsIIdleServiceInternal.h" -#include "nsIRunnable.h" -#include "nsThreadUtils.h" - -#ifdef MOZ_LOGGING - -#include "mozilla/Logging.h" -#include "nsTArray.h" - -extern PRLogModuleInfo *gWidgetLog; -extern PRLogModuleInfo *gWidgetFocusLog; -extern PRLogModuleInfo *gWidgetIMLog; -extern PRLogModuleInfo *gWidgetDrawLog; - -#define LOG(args) MOZ_LOG(gWidgetLog, mozilla::LogLevel::Debug, args) -#define LOGFOCUS(args) MOZ_LOG(gWidgetFocusLog, mozilla::LogLevel::Debug, args) -#define LOGIM(args) MOZ_LOG(gWidgetIMLog, mozilla::LogLevel::Debug, args) -#define LOGDRAW(args) MOZ_LOG(gWidgetDrawLog, mozilla::LogLevel::Debug, args) - -#else - -#ifdef DEBUG_WIDGETS - -#define PR_LOG2(_args) \ - PR_BEGIN_MACRO \ - qDebug _args; \ - PR_END_MACRO - -#define LOG(args) PR_LOG2(args) -#define LOGFOCUS(args) PR_LOG2(args) -#define LOGIM(args) PR_LOG2(args) -#define LOGDRAW(args) PR_LOG2(args) - -#else - -#define LOG(args) -#define LOGFOCUS(args) -#define LOGIM(args) -#define LOGDRAW(args) - -#endif - -#endif /* MOZ_LOGGING */ - -class QCloseEvent; -class QFocusEvent; -class QHideEvent; -class QKeyEvent; -class QMouseEvent; -class QMoveEvent; -class QResizeEvent; -class QShowEvent; -class QTabletEvent; -class QTouchEvent; -class QWheelEvent; - -namespace mozilla { -namespace widget { -class MozQWidget; -class nsWindow : public nsBaseWidget -{ -public: - nsWindow(); - - NS_DECL_ISUPPORTS_INHERITED - - // - // nsIWidget - // - NS_IMETHOD Create(nsIWidget* aParent, - nsNativeWidget aNativeParent, - const LayoutDeviceIntRect& aRect, - nsWidgetInitData* aInitData); - NS_IMETHOD Destroy(void); - - NS_IMETHOD Show(bool aState); - virtual bool IsVisible() const; - NS_IMETHOD ConstrainPosition(bool aAllowSlop, - int32_t *aX, - int32_t *aY); - NS_IMETHOD Move(double aX, - double aY); - NS_IMETHOD Resize(double aWidth, - double aHeight, - bool aRepaint); - NS_IMETHOD Resize(double aX, - double aY, - double aWidth, - double aHeight, - bool aRepaint); - NS_IMETHOD Enable(bool aState); - // Some of the nsIWidget methods - virtual bool IsEnabled() const; - NS_IMETHOD SetFocus(bool aRaise = false); - NS_IMETHOD ConfigureChildren(const nsTArray&); - NS_IMETHOD Invalidate(const LayoutDeviceIntRect& aRect); - virtual void* GetNativeData(uint32_t aDataType); - NS_IMETHOD SetTitle(const nsAString& aTitle); - NS_IMETHOD SetCursor(nsCursor aCursor); - NS_IMETHOD SetCursor(imgIContainer* aCursor, - uint32_t aHotspotX, uint32_t aHotspotY) - { - return NS_OK; - } - virtual LayoutDeviceIntPoint WidgetToScreenOffset(); - NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent, - nsEventStatus& aStatus); - NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, - bool aDoCapture) - { - return NS_ERROR_NOT_IMPLEMENTED; - } - NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent); - - NS_IMETHOD MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen = nullptr); - virtual mozilla::layers::LayerManager* - GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr, - LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE, - LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT); - - NS_IMETHOD_(void) SetInputContext(const InputContext& aContext, - const InputContextAction& aAction); - NS_IMETHOD_(InputContext) GetInputContext(); - - virtual uint32_t GetGLFrameBufferFormat() override; - - already_AddRefed StartRemoteDrawing() override; - - // Widget notifications - virtual void OnPaint(); - virtual nsEventStatus focusInEvent(QFocusEvent* aEvent); - virtual nsEventStatus focusOutEvent(QFocusEvent* aEvent); - virtual nsEventStatus hideEvent(QHideEvent* aEvent); - virtual nsEventStatus showEvent(QShowEvent* aEvent); - virtual nsEventStatus keyPressEvent(QKeyEvent* aEvent); - virtual nsEventStatus keyReleaseEvent(QKeyEvent* aEvent); - virtual nsEventStatus mouseDoubleClickEvent(QMouseEvent* aEvent); - virtual nsEventStatus mouseMoveEvent(QMouseEvent* aEvent); - virtual nsEventStatus mousePressEvent(QMouseEvent* aEvent); - virtual nsEventStatus mouseReleaseEvent(QMouseEvent* aEvent); - virtual nsEventStatus moveEvent(QMoveEvent* aEvent); - virtual nsEventStatus resizeEvent(QResizeEvent* aEvent); - virtual nsEventStatus touchEvent(QTouchEvent* aEvent); - virtual nsEventStatus wheelEvent(QWheelEvent* aEvent); - virtual nsEventStatus tabletEvent(QTabletEvent* event); - -protected: - virtual ~nsWindow(); - - nsWindow* mParent; - bool mVisible; - InputContext mInputContext; - nsCOMPtr mIdleService; - MozQWidget* mWidget; - -private: - // event handling code - nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent); - void DispatchActivateEvent(void); - void DispatchDeactivateEvent(void); - void DispatchActivateEventOnTopLevelWindow(void); - void DispatchDeactivateEventOnTopLevelWindow(void); - void DispatchResizeEvent(LayoutDeviceIntRect &aRect, - nsEventStatus &aStatus); - - // Remember the last sizemode so that we can restore it when - // leaving fullscreen - nsSizeMode mLastSizeMode; - // is this widget enabled? - bool mEnabled; - - // Call this function when the users activity is the direct cause of an - // event (like a keypress or mouse click). - void UserActivity(); - MozQWidget* createQWidget(MozQWidget* parent, - nsWidgetInitData* aInitData); - -public: - // Old QtWidget only - NS_IMETHOD SetParent(nsIWidget* aNewParent); - virtual nsIWidget *GetParent(void); - virtual float GetDPI(); - NS_IMETHOD SetModal(bool aModal); - NS_IMETHOD PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, - nsIWidget *aWidget, - bool aActivate); - NS_IMETHOD SetSizeMode(nsSizeMode aMode); - NS_IMETHOD GetScreenBounds(LayoutDeviceIntRect& aRect) override; - NS_IMETHOD SetHasTransparentBackground(bool aTransparent); - NS_IMETHOD GetHasTransparentBackground(bool& aTransparent); - NS_IMETHOD HideWindowChrome(bool aShouldHide); - NS_IMETHOD SetIcon(const nsAString& aIconSpec); - NS_IMETHOD CaptureMouse(bool aCapture); - NS_IMETHOD SetWindowClass(const nsAString& xulWinType); - NS_IMETHOD GetAttention(int32_t aCycleCount); - NS_IMETHOD_(bool) HasGLContext(); - - // - // utility methods - // - void QWidgetDestroyed(); - // called when we are destroyed - void OnDestroy(void); - // called to check and see if a widget's dimensions are sane - bool AreBoundsSane(void); -private: - // Is this a toplevel window? - bool mIsTopLevel; - // Has this widget been destroyed yet? - bool mIsDestroyed; - // This flag tracks if we're hidden or shown. - bool mIsShown; - // Has anyone set an x/y location for this widget yet? Toplevels - // shouldn't be automatically set to 0,0 for first show. - bool mPlaced; - /** - * Event handlers (proxied from the actual qwidget). - * They follow normal Qt widget semantics. - */ - void Initialize(MozQWidget *widget); - virtual nsEventStatus OnCloseEvent(QCloseEvent *); - void NativeResize(int32_t aWidth, - int32_t aHeight, - bool aRepaint); - void NativeResize(int32_t aX, - int32_t aY, - int32_t aWidth, - int32_t aHeight, - bool aRepaint); - void NativeShow (bool aAction); - -private: - typedef struct { - QPointF pos; - Qt::KeyboardModifiers modifiers; - bool needDispatch; - } MozCachedMoveEvent; - - nsIWidgetListener* GetPaintListener(); - bool CheckForRollup(double aMouseX, double aMouseY, bool aIsWheel); - void* SetupPluginPort(void); - nsresult SetWindowIconList(const nsTArray &aIconList); - void SetDefaultIcon(void); - - nsEventStatus DispatchCommandEvent(nsIAtom* aCommand); - nsEventStatus DispatchContentCommandEvent(mozilla::EventMessage aMsg); - void SetSoftwareKeyboardState(bool aOpen, const InputContextAction& aAction); - void ClearCachedResources(); - - uint32_t mActivatePending : 1; - int32_t mSizeState; - - bool mIsTransparent; - - // all of our DND stuff - // this is the last window that had a drag event happen on it. - void InitDragEvent(mozilla::WidgetMouseEvent& aEvent); - - // this is everything we need to be able to fire motion events - // repeatedly - uint32_t mKeyDownFlags[8]; - - /* Helper methods for DOM Key Down event suppression. */ - uint32_t* GetFlagWord32(uint32_t aKeyCode, uint32_t* aMask) { - /* Mozilla DOM Virtual Key Code is from 0 to 224. */ - NS_ASSERTION((aKeyCode <= 0xFF), "Invalid DOM Key Code"); - aKeyCode &= 0xFF; - - /* 32 = 2^5 = 0x20 */ - *aMask = uint32_t(1) << (aKeyCode & 0x1F); - return &mKeyDownFlags[(aKeyCode >> 5)]; - } - - bool IsKeyDown(uint32_t aKeyCode) { - uint32_t mask; - uint32_t* flag = GetFlagWord32(aKeyCode, &mask); - return ((*flag) & mask) != 0; - } - - void SetKeyDownFlag(uint32_t aKeyCode) { - uint32_t mask; - uint32_t* flag = GetFlagWord32(aKeyCode, &mask); - *flag |= mask; - } - - void ClearKeyDownFlag(uint32_t aKeyCode) { - uint32_t mask; - uint32_t* flag = GetFlagWord32(aKeyCode, &mask); - *flag &= ~mask; - } - int32_t mQCursor; - - - void ProcessMotionEvent(); - - void DispatchMotionToMainThread() { - if (!mTimerStarted) { - nsCOMPtr event = - mozilla::NewRunnableMethod(this, &nsWindow::ProcessMotionEvent); - NS_DispatchToMainThread(event); - mTimerStarted = true; - } - } - - bool mNeedsResize; - bool mNeedsMove; - bool mListenForResizes; - bool mNeedsShow; - MozCachedMoveEvent mMoveEvent; - bool mTimerStarted; -}; - -}} - -#endif /* __nsWindow_h__ */