Bug 1282866 - remove widget/qt and other supporting QT code, r=dougt. This patch does not remove all of the checks for MOZ_WIDGET_QT (which are dead code), but that will be a followup mentored bug.

MozReview-Commit-ID: EGqHHhCD7vD

--HG--
extra : rebase_source : a4b9593959dd3ba80189db47eabb056ea207490f
extra : amend_source : a744d833693f0fe7adbea961c00bb5fb55a91580
This commit is contained in:
Benjamin Smedberg 2016-07-07 12:14:25 -04:00
Родитель 4b4be5ed67
Коммит bf05496a83
72 изменённых файлов: 16 добавлений и 7729 удалений

Просмотреть файл

@ -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',

Просмотреть файл

@ -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',

Просмотреть файл

@ -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

Просмотреть файл

@ -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 <QtCore/QTimer>
#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 */

Просмотреть файл

@ -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 <QtCore/QObject>
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

Просмотреть файл

@ -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 <QtCore/QCoreApplication>
#include <QtCore/QEventLoop>
static const int kMaxtimeToProcessEvents = 30;
bool
PluginHelperQt::AnswerProcessSomeEvents()
{
QCoreApplication::processEvents(QEventLoop::AllEvents, kMaxtimeToProcessEvents);
return true;
}

Просмотреть файл

@ -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',

Просмотреть файл

@ -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 <josh@mozilla.com>
*
* ***** 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)
{
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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>("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<nsGeoPosition> 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;
}

Просмотреть файл

@ -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 <QGeoPositionInfoSource>
#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<nsIGeolocationUpdate> mCallback;
};
#endif /* QTMLocationProvider_h */

Просмотреть файл

@ -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 <QFeedbackEffect>
#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;
}

Просмотреть файл

@ -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() {}
};

Просмотреть файл

@ -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'

Просмотреть файл

@ -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']

Просмотреть файл

@ -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']

Просмотреть файл

@ -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);

Просмотреть файл

@ -1,2 +0,0 @@
component {c0783c34-a831-40c6-8c03-98c9f74cca45} gtkqticonsconverter.js
contract @mozilla.org/gtkqticonsconverter;1 {c0783c34-a831-40c6-8c03-98c9f74cca45}

Просмотреть файл

@ -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']

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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 <QIcon>
#include <stdlib.h>
#include <unistd.h>
#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<nsIStringInputStream> 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<nsIPrincipal> 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<nsIMozIconURI> 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));
}

Просмотреть файл

@ -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<nsIChannel> mRealChannel;
};
#endif // mozilla_image_encoders_icon_qt_nsIconChannel_h

Просмотреть файл

@ -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']

Просмотреть файл

@ -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']

Просмотреть файл

@ -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']

Просмотреть файл

@ -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:

Просмотреть файл

@ -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']

Просмотреть файл

@ -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']

Просмотреть файл

@ -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',

Просмотреть файл

@ -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)

Просмотреть файл

@ -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']

Просмотреть файл

@ -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']

Просмотреть файл

@ -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<nsIObserverService> 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;
}

Просмотреть файл

@ -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_ */

Просмотреть файл

@ -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 <QHostInfo>
#include <QHostAddress>
#include <QTime>
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();
}
}

Просмотреть файл

@ -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 <QNetworkConfigurationManager>
#include <QObject>
#include <QTimer>
#include <QNetworkConfiguration>
#include <QNetworkSession>
#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_ */

Просмотреть файл

@ -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

Просмотреть файл

@ -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',

Просмотреть файл

@ -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

Просмотреть файл

@ -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',
]

Просмотреть файл

@ -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<GfxDriverInfo>&
GfxInfo::GetGfxDriverInfo()
{
return *mDriverInfo;
}
uint32_t GfxInfo::OperatingSystemVersion()
{
return 0;
}
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t /*aFeature*/,
int32_t *aStatus,
nsAString & /*aSuggestedDriverVersion*/,
const nsTArray<GfxDriverInfo>& /*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

Просмотреть файл

@ -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<GfxDriverInfo>& aDriverInfo,
OperatingSystem* aOS = nullptr);
virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo();
};
} // namespace widget
} // namespace mozilla
#endif /* __mozilla_widget_GfxInfo_h__ */

Просмотреть файл

@ -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']

Просмотреть файл

@ -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 <QtCore/QCoreApplication>
#include <QtGui/QResizeEvent>
#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);
}

Просмотреть файл

@ -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 <QtGui/QWindow>
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

Просмотреть файл

@ -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 <QGuiApplication>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <qabstracteventdispatcher.h>
#include <qthread.h>
#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;
}

Просмотреть файл

@ -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 <qsocketnotifier.h>
#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__

Просмотреть файл

@ -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 <Qt>
#include <QGuiApplication>
#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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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 <QGuiApplication>
#include <QMimeData>
#include <QString>
#include <QStringList>
#include <QByteArray>
#include <QImage>
#include <QImageWriter>
#include <QBuffer>
#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<nsISupportsArray> 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<nsISupports> genericFlavor;
flavorList->GetElementAt(i,getter_AddRefs(genericFlavor));
nsCOMPtr<nsISupportsCString> 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<nsISupports> 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<nsISupportsString> 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<nsISupportsString> 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<nsISupportsInterfacePointer> 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<nsISupports> primitiveData;
ptrPrimitive->GetData(getter_AddRefs(primitiveData));
nsCOMPtr<imgIContainer> image(do_QueryInterface(primitiveData));
if (!image) // Not getting an image for an image mime type!?
continue;
RefPtr<SourceSurface> surface =
image->GetFrame(imgIContainer::FRAME_CURRENT,
imgIContainer::FLAG_SYNC_DECODE);
if (!surface)
continue;
RefPtr<DataSourceSurface> 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<nsISupportsArray> 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<nsISupports> genericFlavor;
flavorList->GetElementAt(i,getter_AddRefs(genericFlavor));
nsCOMPtr<nsISupportsCString> 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<nsISupports> 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<nsISupports> 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<nsIInputStream> 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<nsISupports> 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;
}

Просмотреть файл

@ -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 <qclipboard.h>
/* 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<nsIClipboardOwner> mSelectionOwner;
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> mSelectionTransferable;
nsCOMPtr<nsITransferable> mGlobalTransferable;
};
#endif // nsClipboard_h__

Просмотреть файл

@ -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 <QTemporaryFile>
#include <QPrinterInfo>
#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 <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
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<PrintTarget> 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<nsIFileOutputStream> 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<nsPrintSettingsQt> 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<nsIFile> 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<nsIFile> 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<QPrinterInfo> qprinters = QPrinterInfo::availablePrinters();
if (qprinters.size() == 0)
return NS_ERROR_NOT_AVAILABLE;
nsTArray<nsString>* printers =
new nsTArray<nsString>(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;
}

Просмотреть файл

@ -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 <limits.h>? */
class nsDeviceContextSpecQt : public nsIDeviceContextSpec
{
public:
nsDeviceContextSpecQt();
NS_DECL_ISUPPORTS
virtual already_AddRefed<PrintTarget> 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<nsIPrintSettings> 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<nsIFile> mSpoolFile;
};
class nsPrinterEnumeratorQt : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorQt();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
protected:
virtual ~nsPrinterEnumeratorQt();
};
#endif /* !nsDeviceContextSpecQt_h___ */

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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 <X11/Xlib.h>
#include <X11/Xutil.h>
typedef struct {
Window window; // Screen saver window
int state; // ScreenSaver(Off,On,Disabled)
int kind; // ScreenSaver(Blanked,Internal,External)
unsigned long til_or_since; // milliseconds since/til screensaver kicks in
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<nsIdleServiceQt> GetInstance()
{
RefPtr<nsIdleServiceQt> idleService =
nsIdleService::GetInstance().downcast<nsIdleServiceQt>();
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__

Просмотреть файл

@ -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 <QGuiApplication>
#include <QFont>
#include <QScreen>
#include <QPalette>
#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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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__ */

Просмотреть файл

@ -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 <QPrinter>
#include <QDebug>
#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<nsPrintSettingsQt*>(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<nsIFile> 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()<<Q_FUNC_INFO;
qDebug()<<"Scaling not implemented in Qt port";
*aScaling = 1.0; //FIXME
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetScaling(double aScaling)
{
qDebug()<<Q_FUNC_INFO;
qDebug()<<"Scaling not implemented in Qt port"; //FIXME
return NS_ERROR_NOT_IMPLEMENTED;
}
static const char* const indexToPaperName[] =
{ "A4", "B5", "Letter", "Legal", "Executive",
"A0", "A1", "A2", "A3", "A5", "A6", "A7", "A8", "A9",
"B0", "B1", "B10", "B2", "B3", "B4", "B6", "B7", "B8", "B9",
"C5E", "Comm10E", "DLE", "Folio", "Ledger", "Tabloid"
};
static const QPrinter::PageSize indexToQtPaperEnum[] =
{
QPrinter::A4, QPrinter::B5, QPrinter::Letter, QPrinter::Legal,
QPrinter::Executive, QPrinter::A0, QPrinter::A1, QPrinter::A2, QPrinter::A3,
QPrinter::A5, QPrinter::A6, QPrinter::A7, QPrinter::A8, QPrinter::A9,
QPrinter::B0, QPrinter::B1, QPrinter::B10, QPrinter::B2, QPrinter::B3,
QPrinter::B4, QPrinter::B6, QPrinter::B7, QPrinter::B8, QPrinter::B9,
QPrinter::C5E, QPrinter::Comm10E, QPrinter::DLE, QPrinter::Folio,
QPrinter::Ledger, QPrinter::Tabloid
};
NS_IMETHODIMP
nsPrintSettingsQt::GetPaperName(char16_t** aPaperName)
{
QPrinter::PaperSize size = mQPrinter->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;
}

Просмотреть файл

@ -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 <QSharedPointer>
#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<QPrinter> mQPrinter;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsQt, NS_PRINTSETTINGSQT_IID)
#endif // nsPrintSettingsQt_h_

Просмотреть файл

@ -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 <qnamespace.h>
#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;
}
}

Просмотреть файл

@ -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__ */

Просмотреть файл

@ -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 <QGuiApplication>
#include <QScreen>
#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<nsIScreen>[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&rect;
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);
}

Просмотреть файл

@ -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<nsIScreen> *screens;
QDesktopWidget *desktop;
int nScreens;
bool mInitialized;
};
#endif // nsScreenManagerQt_h___

Просмотреть файл

@ -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 <QColor>
#include <QRect>
#include <QGuiApplication>
#include <QTransform>
#include <QScreen>
#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);
}

Просмотреть файл

@ -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___

Просмотреть файл

@ -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;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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 <QPointF>
#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<nsIWidget::Configuration>&);
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<mozilla::gfx::DrawTarget> 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<nsIIdleServiceInternal> 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<nsCString> &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<nsIRunnable> 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__ */