Skip to content

Commit

Permalink
Revert "Bug 1282866 - remove widget/qt and other supporting QT code, …
Browse files Browse the repository at this point in the history
…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."

This reverts commit bf05496.

This does not revert back pango configuration as it seems to be already removed.
  • Loading branch information
rainemak committed May 27, 2020
1 parent e4d4e29 commit 86a59a2
Show file tree
Hide file tree
Showing 72 changed files with 7,701 additions and 15 deletions.
1 change: 1 addition & 0 deletions build/moz.configure/old.configure
Expand Up @@ -278,6 +278,7 @@ def old_configure_options(*options):
'--with-nss-prefix',
'--with-pthreads',
'--with-qemu-exe',
'--with-qtdir',
'--with-sixgill',
'--with-soft-float',
'--with-system-bz2',
Expand Down
6 changes: 6 additions & 0 deletions dom/geolocation/moz.build
Expand Up @@ -26,6 +26,12 @@ 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',
Expand Down
8 changes: 8 additions & 0 deletions dom/geolocation/nsGeolocation.cpp
Expand Up @@ -29,6 +29,10 @@

class nsIPrincipal;

#ifdef MOZ_ENABLE_QT5GEOPOSITION
#include "QTMLocationProvider.h"
#endif

#ifdef MOZ_WIDGET_ANDROID
#include "AndroidLocationProvider.h"
#endif
Expand Down Expand Up @@ -684,6 +688,10 @@ 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
Expand Down
48 changes: 48 additions & 0 deletions dom/plugins/ipc/NestedLoopTimer.cpp
@@ -0,0 +1,48 @@
/* -*- 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 */
41 changes: 41 additions & 0 deletions dom/plugins/ipc/NestedLoopTimer.h
@@ -0,0 +1,41 @@
/* -*- 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
18 changes: 18 additions & 0 deletions dom/plugins/ipc/PluginHelperQt.cpp
@@ -0,0 +1,18 @@
/* -*- 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;
}
7 changes: 7 additions & 0 deletions dom/plugins/ipc/moz.build
Expand Up @@ -67,6 +67,13 @@ 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',
Expand Down
103 changes: 103 additions & 0 deletions dom/plugins/test/testplugin/nptest_qt.cpp
@@ -0,0 +1,103 @@
/* ***** 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)
{
}
11 changes: 11 additions & 0 deletions dom/plugins/test/testplugin/testplugin.mozbuild
Expand Up @@ -26,6 +26,10 @@ elif toolkit == 'android':
UNIFIED_SOURCES += [
'nptest_droid.cpp',
]
elif toolkit == 'qt':
UNIFIED_SOURCES += [
'nptest_qt.cpp',
]
elif toolkit == 'windows':
UNIFIED_SOURCES += [
'nptest_windows.cpp',
Expand Down Expand Up @@ -57,6 +61,13 @@ 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
Expand Down
101 changes: 101 additions & 0 deletions dom/system/qt/QTMLocationProvider.cpp
@@ -0,0 +1,101 @@
/* -*- 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;
}

0 comments on commit 86a59a2

Please sign in to comment.