Bug 694206 - Add Gonk (B2G) widget backend, r=cjones

This commit is contained in:
Michael Wu 2011-11-10 16:17:46 -08:00
Родитель 335f0043ea
Коммит 5dd6a67845
67 изменённых файлов: 2628 добавлений и 124 удалений

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

@ -65,7 +65,7 @@ tier_base_dirs = \
$(NULL)
ifndef LIBXUL_SDK
ifeq ($(OS_TARGET),Android)
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
tier_base_dirs += other-licenses/android
endif

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

@ -56,7 +56,7 @@ endif
DIRS += pgo
ifdef ENABLE_TESTS
ifeq (Android,$(OS_TARGET))
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
DIRS += mobile/sutagent/android \
mobile/sutagent/android/watcher \
mobile/sutagent/android/ffxcp \

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

@ -289,6 +289,56 @@ arm-android-eabi)
;;
esac
MOZ_ARG_WITH_STRING(gonk,
[ --with-gonk=DIR
location of gonk dir],
gonkdir=$withval)
if test -n "$gonkdir" ; then
kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
gonk_toolchain="$gonkdir"/prebuilt/$kernel_name-x86/toolchain/arm-eabi-4.4.3
dnl set up compilers
AS="$gonk_toolchain"/bin/"$android_tool_prefix"-as
CC="$gonk_toolchain"/bin/"$android_tool_prefix"-gcc
CXX="$gonk_toolchain"/bin/"$android_tool_prefix"-g++
CPP="$gonk_toolchain"/bin/"$android_tool_prefix"-cpp
LD="$gonk_toolchain"/bin/"$android_tool_prefix"-ld
AR="$gonk_toolchain"/bin/"$android_tool_prefix"-ar
RANLIB="$gonk_toolchain"/bin/"$android_tool_prefix"-ranlib
STRIP="$gonk_toolchain"/bin/"$android_tool_prefix"-strip
STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/"
STLPORT_LIBS="-lstlport"
CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/system/core/include -I$gonkdir/bionic -I$gonkdir/frameworks/base/include $STLPORT_CPPFLAGS $CPPFLAGS"
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
LIBS="$LIBS $STLPORT_LIBS"
dnl Add -llog by default, since we use it all over the place.
LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ -llog $LDFLAGS"
dnl prevent cross compile section from using these flags as host flags
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
AC_DEFINE(ANDROID)
CROSS_COMPILE=1
MOZ_CHROME_FILE_FORMAT=omni
ZLIB_DIR=yes
direct_nspr_config=1
else
case "$target" in
*-android*|*-linuxandroid*)
if test -z "$android_ndk" ; then
@ -419,6 +469,8 @@ case "$target" in
;;
esac
fi
AC_SUBST(ANDROID_NDK)
AC_SUBST(ANDROID_TOOLCHAIN)
AC_SUBST(ANDROID_PLATFORM)
@ -2386,7 +2438,11 @@ ia64*-hpux*)
*-android*|*-linuxandroid*)
AC_DEFINE(NO_PW_GECOS)
no_x=yes
_PLATFORM_DEFAULT_TOOLKIT=cairo-android
if test -n "$gonkdir"; then
_PLATFORM_DEFAULT_TOOLKIT=cairo-gonk
else
_PLATFORM_DEFAULT_TOOLKIT=cairo-android
fi
TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
MOZ_GFX_OPTIMIZE_MOBILE=1
@ -4772,7 +4828,8 @@ MOZ_ARG_HEADER(Toolkit Options)
-o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
-o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
-o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
-o "$_DEFAULT_TOOLKIT" = "cairo-android"
-o "$_DEFAULT_TOOLKIT" = "cairo-android" \
-o "$_DEFAULT_TOOLKIT" = "cairo-gonk"
then
dnl nglayout only supports building with one toolkit,
dnl so ignore everything after the first comma (",").
@ -4895,6 +4952,15 @@ cairo-android)
MOZ_INSTRUMENT_EVENT_LOOP=1
;;
cairo-gonk)
AC_DEFINE(MOZ_WIDGET_GONK)
MOZ_WIDGET_TOOLKIT=gonk
TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
TK_LIBS='$(MOZ_CAIRO_LIBS)'
MOZ_WEBGL=1
MOZ_PDF_PRINTING=1
;;
esac
AC_SUBST(MOZ_PDF_PRINTING)
@ -7175,7 +7241,9 @@ dnl We need to wrap dlopen and related functions on Android because we use
dnl our own linker.
if test "$OS_TARGET" = Android; then
WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozutils"
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
if test "$MOZ_WIDGET_TOOLKIT" = android; then
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
fi
fi
dnl ========================================================
@ -8856,20 +8924,22 @@ if test "$MOZ_TREE_FREETYPE"; then
AC_OUTPUT_SUBDIRS(modules/freetype2)
fi
dnl ========================================================
dnl = Setup a nice relatively clean build environment for
dnl = sub-configures.
dnl ========================================================
CC="$_SUBDIR_CC"
CXX="$_SUBDIR_CXX"
CFLAGS="$_SUBDIR_CFLAGS"
CPPFLAGS="$_SUBDIR_CPPFLAGS"
CXXFLAGS="$_SUBDIR_CXXFLAGS"
LDFLAGS="$_SUBDIR_LDFLAGS"
HOST_CC="$_SUBDIR_HOST_CC"
HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
RC=
if test -z "$direct_nspr_config"; then
dnl ========================================================
dnl = Setup a nice relatively clean build environment for
dnl = sub-configures.
dnl ========================================================
CC="$_SUBDIR_CC"
CXX="$_SUBDIR_CXX"
CFLAGS="$_SUBDIR_CFLAGS"
CPPFLAGS="$_SUBDIR_CPPFLAGS"
CXXFLAGS="$_SUBDIR_CXXFLAGS"
LDFLAGS="$_SUBDIR_LDFLAGS"
HOST_CC="$_SUBDIR_HOST_CC"
HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
RC=
fi
unset MAKEFILES
unset CONFIG_FILES
@ -8918,6 +8988,23 @@ if test -z "$MOZ_NATIVE_NSPR"; then
rm -f config/autoconf.mk.bak
fi
if test -n "$direct_nspr_config"; then
dnl ========================================================
dnl = Setup a nice relatively clean build environment for
dnl = sub-configures.
dnl ========================================================
CC="$_SUBDIR_CC"
CXX="$_SUBDIR_CXX"
CFLAGS="$_SUBDIR_CFLAGS"
CPPFLAGS="$_SUBDIR_CPPFLAGS"
CXXFLAGS="$_SUBDIR_CXXFLAGS"
LDFLAGS="$_SUBDIR_LDFLAGS"
HOST_CC="$_SUBDIR_HOST_CC"
HOST_CFLAGS="$_SUBDIR_HOST_CFLAGS"
HOST_LDFLAGS="$_SUBDIR_HOST_LDFLAGS"
RC=
fi
# Run the SpiderMonkey 'configure' script.
dist=$MOZ_BUILD_ROOT/dist
ac_configure_args="$_SUBDIR_CONFIG_ARGS"

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

@ -57,10 +57,10 @@
#ifdef MOZ_ENABLE_DBUS
#include "nsDBusHandlerApp.h"
#endif
#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
#include "nsExternalSharingAppService.h"
#endif
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
#include "nsExternalURLHandlerService.h"
#endif
@ -118,10 +118,10 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t)
#ifdef MOZ_ENABLE_DBUS
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp)
#endif
#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalSharingAppService)
#endif
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
#endif
@ -148,10 +148,10 @@ NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_CID);
#ifdef MOZ_ENABLE_DBUS
NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID);
#endif
#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAPPSERVICE_CID);
#endif
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
@ -178,10 +178,10 @@ const mozilla::Module::CIDEntry kDocShellCIDs[] = {
#ifdef MOZ_ENABLE_DBUS
{ &kNS_DBUSHANDLERAPP_CID, false, NULL, nsDBusHandlerAppConstructor },
#endif
#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
{ &kNS_EXTERNALSHARINGAPPSERVICE_CID, false, NULL, nsExternalSharingAppServiceConstructor },
#endif
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
{ &kNS_EXTERNALURLHANDLERSERVICE_CID, false, NULL, nsExternalURLHandlerServiceConstructor },
#endif
{ &kNS_SHENTRY_CID, false, NULL, nsSHEntryConstructor },
@ -227,10 +227,10 @@ const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
#ifdef MOZ_ENABLE_DBUS
{ NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID },
#endif
#if defined(ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_ENABLE_MEEGOTOUCHSHARE)
{ NS_EXTERNALSHARINGAPPSERVICE_CONTRACTID, &kNS_EXTERNALSHARINGAPPSERVICE_CID },
#endif
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
{ NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
#endif
{ NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },

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

@ -98,7 +98,7 @@
#include "nsDeviceMotion.h"
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
#include "APKOpen.h"
#endif
@ -272,7 +272,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
#ifdef MOZ_CRASHREPORTER
SendPCrashReporterConstructor(CrashReporter::CurrentThreadId(),
XRE_GetProcessType());
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
PCrashReporterChild* crashreporter = ManagedPCrashReporterChild()[0];
InfallibleTArray<Mapping> mappings;

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

@ -106,6 +106,8 @@
#ifdef ANDROID
#include "gfxAndroidPlatform.h"
#endif
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -636,7 +638,7 @@ ContentParent::RecvClipboardHasText(bool* hasText)
bool
ContentParent::RecvGetSystemColors(const PRUint32& colorsCount, InfallibleTArray<PRUint32>* colors)
{
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
NS_ASSERTION(AndroidBridge::Bridge() != nsnull, "AndroidBridge is not available");
if (AndroidBridge::Bridge() == nsnull) {
// Do not fail - the colors won't be right, but it's not critical
@ -655,7 +657,7 @@ ContentParent::RecvGetSystemColors(const PRUint32& colorsCount, InfallibleTArray
bool
ContentParent::RecvGetIconForExtension(const nsCString& aFileExt, const PRUint32& aIconSize, InfallibleTArray<PRUint8>* bits)
{
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
NS_ASSERTION(AndroidBridge::Bridge() != nsnull, "AndroidBridge is not available");
if (AndroidBridge::Bridge() == nsnull) {
// Do not fail - just no icon will be shown
@ -674,7 +676,7 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
{
// default behavior is to show the last password character
*showPassword = true;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
NS_ASSERTION(AndroidBridge::Bridge() != nsnull, "AndroidBridge is not available");
if (AndroidBridge::Bridge() != nsnull)
*showPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();

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

@ -51,7 +51,7 @@ static int gNotOptimized;
#define CALLING_CONVENTION_HACK
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#include "android_npapi.h"
#include <android/log.h>
@ -59,7 +59,7 @@ static int gNotOptimized;
#endif
namespace mozilla {
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error)
@ -82,10 +82,16 @@ PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
mNPP_GetSitesWithData = pFuncs->getsiteswithdata;
return NS_OK;
}
#elif defined(MOZ_WIDGET_GONK)
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
{
return NS_OK;
}
#elif defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error)
NPPluginFuncs* pFuncs, NPError* error)
{
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs, pFuncs);

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

@ -114,7 +114,7 @@ public:
return true;
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error);
#else

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

@ -48,7 +48,7 @@
#include "npapi.h"
#include "npruntime.h"
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include <jni.h>
#endif
@ -311,7 +311,7 @@ NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs);
typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*);
NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs);
#else
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv);
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv);
#else

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

@ -131,7 +131,7 @@ using mozilla::plugins::PluginModuleParent;
#include <windows.h>
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include "AndroidBridge.h"
#include <android/log.h>
@ -488,7 +488,7 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
return NS_ERROR_FAILURE;
}
#if defined(XP_MACOSX) || defined(ANDROID)
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
if (!pluginLib->HasRequiredFunctions()) {
NS_WARNING("Not all necessary functions exposed by plugin, it will not load.");
return NS_ERROR_FAILURE;
@ -526,6 +526,7 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
return NS_ERROR_FAILURE;
}
#elif defined(MOZ_WIDGET_GONK)
#else
rv = pluginLib->NP_Initialize(&sBrowserFuncs, &plugin->mPluginFuncs, &pluginCallError);
if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
@ -2298,7 +2299,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
}
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
case kLogInterfaceV0_ANPGetValue: {
LOG("get log interface");
ANPLogInterfaceV0 *i = (ANPLogInterfaceV0 *) result;
@ -2515,7 +2516,7 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
}
}
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
case kRequestDrawingModel_ANPSetValue:
if (inst)
inst->SetDrawingModel(NS_PTR_TO_INT32(result));

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

@ -61,7 +61,7 @@
#include "nsNetCID.h"
#include "nsIContent.h"
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include <android/log.h>
#include "android_npapi.h"
@ -72,7 +72,7 @@
using namespace mozilla;
using namespace mozilla::plugins::parent;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include <map>
static std::map<void*, nsNPAPIPluginInstance*> sSurfaceMap;
#endif
@ -91,7 +91,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
mDrawingModel(NPDrawingModelQuickDraw),
#endif
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
mSurface(nsnull),
mTargetSurface(nsnull),
mDrawingModel(0),
@ -127,7 +127,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
mUsePluginLayersPref = useLayersPref;
}
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
mTargetSurfaceLock = new Mutex("nsNPAPIPluginInstance::SurfaceLock");
#endif
@ -143,7 +143,7 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
mMIMEType = nsnull;
}
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
if (mSurface) {
sSurfaceMap.erase(mSurface);
}
@ -364,7 +364,7 @@ nsNPAPIPluginInstance::InitializePlugin()
const char* const* pvalues = nsnull;
if (NS_SUCCEEDED(GetParameters(pcount, pnames, pvalues))) {
// Android expects an empty string as the separator instead of null
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
NS_ASSERTION(PL_strcmp(values[count], "") == 0, "attribute/parameter array not setup correctly for Android NPAPI plugins");
#else
NS_ASSERTION(!values[count], "attribute/parameter array not setup correctly for NPAPI plugins");
@ -747,7 +747,7 @@ void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
}
#endif
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
void nsNPAPIPluginInstance::SetDrawingModel(PRUint32 aModel)
{
mDrawingModel = aModel;
@ -859,7 +859,7 @@ nsNPAPIPluginInstance::FindByJavaSurface(void* aJavaSurface)
nsresult nsNPAPIPluginInstance::GetDrawingModel(PRInt32* aModel)
{
#if defined(XP_MACOSX) || defined(ANDROID)
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
*aModel = (PRInt32)mDrawingModel;
return NS_OK;
#else
@ -958,7 +958,7 @@ nsNPAPIPluginInstance::DefineJavaProperties()
nsresult
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
{
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// On android, pre-honeycomb, all plugins are treated as windowless.
*isWindowless = true;
#else

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

@ -93,7 +93,7 @@ public:
nsresult NewStreamToPlugin(nsIPluginStreamListener** listener);
nsresult NewStreamFromPlugin(const char* type, const char* target, nsIOutputStream* *result);
nsresult Print(NPPrint* platformPrint);
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
nsresult PostEvent(void* event) { return 0; };
#endif
nsresult HandleEvent(void* event, PRInt16* result);
@ -152,7 +152,7 @@ public:
void SetEventModel(NPEventModel aModel);
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
void SetDrawingModel(PRUint32 aModel);
void* GetJavaSurface();
@ -230,7 +230,7 @@ protected:
NPDrawingModel mDrawingModel;
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
PRUint32 mDrawingModel;
#endif
@ -277,7 +277,7 @@ private:
nsCOMPtr<nsIURI> mURI;
bool mUsePluginLayersPref;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
void InvalidateTargetRect();
void* mSurface;

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

@ -118,7 +118,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#include "gfxXlibNativeRenderer.h"
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include "android_npapi.h"
#include "AndroidBridge.h"
@ -1280,7 +1280,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// Add PARAM and null separator.
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// Flash expects an empty string on android
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING(""));
#else
@ -1672,7 +1672,7 @@ void nsPluginInstanceOwner::ScrollPositionDidChange(nscoord aX, nscoord aY)
#endif
}
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
void nsPluginInstanceOwner::AddPluginView(const gfxRect& aRect)
{
void* javaSurface = mInstance->GetJavaSurface();
@ -1714,7 +1714,7 @@ void nsPluginInstanceOwner::RemovePluginView()
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
{
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
{
ANPEvent event;
event.inSize = sizeof(ANPEvent);
@ -2527,7 +2527,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
rv = nsEventStatus_eConsumeNoDefault;
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// this code supports windowless plugins
{
// The plugin needs focus to receive keyboard and touch events
@ -2733,7 +2733,7 @@ nsPluginInstanceOwner::PrepareToStop(bool aDelayedStop)
}
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
RemovePluginView();
#endif
@ -2833,7 +2833,7 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HPS aHPS)
}
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
void nsPluginInstanceOwner::Paint(gfxContext* aContext,
const gfxRect& aFrameRect,
@ -3556,7 +3556,7 @@ void nsPluginInstanceOwner::UpdateWindowPositionAndClipRect(bool aSetWindow)
if (mPluginWindowVisible && mPluginDocumentActiveState) {
mPluginWindow->clipRect.right = mPluginWindow->width;
mPluginWindow->clipRect.bottom = mPluginWindow->height;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
if (mInstance) {
ANPEvent event;
event.inSize = sizeof(ANPEvent);
@ -3568,7 +3568,7 @@ void nsPluginInstanceOwner::UpdateWindowPositionAndClipRect(bool aSetWindow)
} else {
mPluginWindow->clipRect.right = 0;
mPluginWindow->clipRect.bottom = 0;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
if (mInstance) {
ANPEvent event;
event.inSize = sizeof(ANPEvent);

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

@ -78,7 +78,7 @@ public:
virtual bool HasRequiredFunctions() = 0;
#if defined(XP_UNIX) && !defined(XP_MACOSX)
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) = 0;
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) = 0;

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

@ -735,7 +735,7 @@ PluginModuleParent::EndUpdateBackground(NPP instance,
return i->EndUpdateBackground(aCtx, aRect);
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
nsresult
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
{

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

@ -276,7 +276,7 @@ private:
gfxContext* aCtx,
const nsIntRect& aRect);
#if defined(XP_UNIX) && !defined(XP_MACOSX)
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);
#else
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);

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

@ -84,7 +84,7 @@
#include "QTMLocationProvider.h"
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidLocationProvider.h"
#endif
@ -595,7 +595,7 @@ nsresult nsGeolocationService::Init()
mProviders.AppendObject(provider);
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
provider = new AndroidLocationProvider();
if (provider)
mProviders.AppendObject(provider);

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

@ -53,7 +53,7 @@ XPCSHELL_TESTS = tests/unit
DIRS += test
endif
ifeq ($(OS_TARGET),Android)
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
DIRS += android
endif

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

@ -205,7 +205,7 @@ CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS) $(PS_CSRCS)
EXPORTS_cairo += $(PDF_EXPORTS) $(PS_EXPORTS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
ifneq (,$(filter android gonk,$(MOZ_WIDGET_TOOLKIT)))
CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS)
EXPORTS_cairo += $(PDF_EXPORTS)
endif

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

@ -109,6 +109,10 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CPPSRCS += nsSystemFontsAndroid.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
CPPSRCS += nsSystemFontsAndroid.cpp
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CMMSRCS = nsSystemFontsMac.mm
endif

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

@ -76,7 +76,11 @@ static nsSystemFontsMac *gSystemFonts = nsnull;
#include "nsSystemFontsQt.h"
#include "gfxPDFSurface.h"
static nsSystemFontsQt *gSystemFonts = nsnull;
#elif defined(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
#include "nsSystemFontsAndroid.h"
#include "gfxPDFSurface.h"
static nsSystemFontsAndroid *gSystemFonts = nsnull;
#elif defined(MOZ_WIDGET_GONK)
#include "nsSystemFontsAndroid.h"
#include "gfxPDFSurface.h"
static nsSystemFontsAndroid *gSystemFonts = nsnull;

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

@ -52,6 +52,8 @@
#define GLdouble_defined 1
// we're using default display for now
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->winId()
#elif defined(MOZ_WIDGET_GONK)
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
#endif
#if defined(MOZ_X11)
@ -63,7 +65,10 @@
#if defined(ANDROID)
/* from widget */
#if defined(MOZ_WIDGET_ANDROID)
#include "AndroidBridge.h"
#endif
#include <android/log.h>
#define EGL_LIB "/system/lib/libEGL.so"
#define GLES2_LIB "/system/lib/libGLESv2.so"
#else
@ -156,6 +161,10 @@ static bool gUseBackingSurface = true;
static bool gUseBackingSurface = false;
#endif
#ifdef MOZ_WIDGET_GONK
extern nsIntRect gScreenBounds;
#endif
namespace mozilla {
namespace gl {
@ -300,6 +309,10 @@ public:
pfnCreateImageKHR fCreateImageKHR;
typedef EGLBoolean (GLAPIENTRY * pfnDestroyImageKHR)(EGLDisplay dpy, EGLImageKHR image);
pfnDestroyImageKHR fDestroyImageKHR;
#ifdef MOZ_WIDGET_GONK
typedef EGLBoolean (GLAPIENTRY * pfnSetSwapRectangleANDROID)(EGLDisplay dpy, EGLSurface surface, EGLint left, EGLint top, EGLint width, EGLint height);
pfnSetSwapRectangleANDROID fSetSwapRectangleANDROID;
#endif
// New extension which allow us to lock texture and get raw image pointer
typedef EGLBoolean (GLAPIENTRY * pfnLockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
@ -396,6 +409,9 @@ public:
SYMBOL(BindTexImage),
SYMBOL(ReleaseTexImage),
SYMBOL(QuerySurface),
#ifdef MOZ_WIDGET_GONK
SYMBOL(SetSwapRectangleANDROID),
#endif
{ NULL, { NULL } }
};
@ -596,7 +612,7 @@ public:
fGetConfigs(mEGLDisplay, ec, nc, &nc);
for (int i = 0; i < nc; ++i) {
printf_stderr ("========= EGL Config %d ========\n");
printf_stderr ("========= EGL Config %d ========\n", i);
DumpEGLConfig(ec[i]);
}
@ -869,6 +885,7 @@ public:
bool SwapBuffers()
{
if (mSurface && !mPlatformContext) {
//sEGLLibrary.fSetSwapRectangleANDROID(EGL_DISPLAY(), mSurface, 0, 0, gScreenBounds.width, gScreenBounds.height);
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), mSurface);
} else {
return false;
@ -1874,7 +1891,7 @@ CreateSurfaceForWindow(nsIWidget *aWidget, EGLConfig config)
sEGLLibrary.DumpEGLConfig(config);
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// On Android, we have to ask Java to make the eglCreateWindowSurface
// call for us. See GLHelpers.java for a description of why.
//
@ -1889,6 +1906,13 @@ CreateSurfaceForWindow(nsIWidget *aWidget, EGLConfig config)
surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, GET_NATIVE_WINDOW(aWidget), 0);
#endif
#ifdef MOZ_WIDGET_GONK
gScreenBounds.x = 0;
gScreenBounds.y = 0;
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), surface, LOCAL_EGL_WIDTH, &gScreenBounds.width);
sEGLLibrary.fQuerySurface(EGL_DISPLAY(), surface, LOCAL_EGL_HEIGHT, &gScreenBounds.height);
#endif
return surface;
}

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

@ -64,6 +64,14 @@ EXPORTS += \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
EXPORTS += \
gfxAndroidPlatform.h \
gfxFT2Fonts.h \
gfxFT2FontBase.h \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
EXPORTS += \
gfxPlatformMac.h \
@ -242,6 +250,21 @@ CPPSRCS += \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
EXPORTS += \
gfxPDFSurface.h \
$(NULL)
CPPSRCS += \
gfxAndroidPlatform.cpp \
gfxFT2Fonts.cpp \
gfxFT2FontBase.cpp \
gfxFT2Utils.cpp \
gfxFT2FontList.cpp \
gfxPDFSurface.cpp \
nsUnicodeRange.cpp \
$(NULL)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS += gfxOS2Fonts.cpp \
gfxOS2Platform.cpp \
@ -354,6 +377,10 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),android)
GL_PROVIDER = EGL
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
GL_PROVIDER = EGL
endif
# Mac is a special snowflake
ifeq ($(GL_PROVIDER),CGL)
CMMSRCS += GLContextProvider$(GL_PROVIDER).mm
@ -380,6 +407,10 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CXXFLAGS += $(CAIRO_FT_CFLAGS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
CXXFLAGS += $(CAIRO_FT_CFLAGS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CXXFLAGS += $(MOZ_PANGO_CFLAGS)
endif

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

@ -82,7 +82,7 @@ endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
DIRS = icon/mac icon
endif
ifeq ($(OS_TARGET),Android)
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
DIRS = icon/android icon
endif

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

@ -27,7 +27,7 @@
#include "base/message_pump_qt.h"
#endif
#endif
#ifdef MOZ_WIDGET_ANDROID
#ifdef ANDROID
#include "base/message_pump_android.h"
#endif

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

@ -70,14 +70,14 @@
#define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "APKOpen.h"
#endif
using mozilla::MonitorAutoLock;
using mozilla::ipc::GeckoChildProcessHost;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// Like its predecessor in nsExceptionHandler.cpp, this is
// the magic number of a file descriptor remapping we must
// preserve for the child process.
@ -446,9 +446,9 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
nsCString path;
greDir->GetNativePath(path);
# ifdef OS_LINUX
# ifdef ANDROID
# ifdef MOZ_WIDGET_ANDROID
path += "/lib";
# endif // ANDROID
# endif // MOZ_WIDGET_ANDROID
const char *ld_library_path = PR_GetEnv("LD_LIBRARY_PATH");
nsCString new_ld_lib_path;
if (ld_library_path && *ld_library_path) {
@ -489,7 +489,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
FilePath exePath;
GetPathToBinary(exePath);
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// The java wrapper unpacks this for us but can't make it executable
chmod(exePath.value().c_str(), 0700);
int cacheCount = 0;
@ -521,7 +521,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
snprintf(buf, sizeof(buf), "%d%s", kMagicAndroidSystemPropFd, szptr);
newEnvVars["ANDROID_PROPERTY_WORKSPACE"] = buf;
}
#endif // ANDROID
#endif // MOZ_WIDGET_ANDROID
// remap the IPC socket fd to a well-known int, as the OS does for
// STDOUT_FILENO, for example
@ -589,7 +589,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector<std::string>& aExt
childArgv.push_back(childProcessType);
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
childArgv.push_back(cacheStr.get());
#endif

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

@ -281,6 +281,60 @@ i?86-*android*)
;;
esac
MOZ_ARG_WITH_STRING(gonk,
[ --with-gonk=DIR
location of gonk dir],
gonkdir=$withval)
if test -n "$gonkdir" ; then
kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
gonk_toolchain="$gonkdir"/prebuilt/$kernel_name-x86/toolchain/arm-eabi-4.4.3
dnl set up compilers
AS="$gonk_toolchain"/bin/"$android_tool_prefix"-as
CC="$gonk_toolchain"/bin/"$android_tool_prefix"-gcc
CXX="$gonk_toolchain"/bin/"$android_tool_prefix"-g++
CPP="$gonk_toolchain"/bin/"$android_tool_prefix"-cpp
LD="$gonk_toolchain"/bin/"$android_tool_prefix"-ld
AR="$gonk_toolchain"/bin/"$android_tool_prefix"-ar
RANLIB="$gonk_toolchain"/bin/"$android_tool_prefix"-ranlib
STRIP="$gonk_toolchain"/bin/"$android_tool_prefix"-strip
STLPORT_CPPFLAGS="-I$gonkdir/external/stlport/stlport"
STLPORT_LIBS="-lstlport"
CPPFLAGS="-DANDROID -I$gonkdir/bionic/libc/include/ -I$gonkdir/bionic/libc/kernel/common -I$gonkdir/bionic/libc/arch-arm/include -I$gonkdir/bionic/libc/kernel/arch-arm -I$gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/system/core/include -I$gonkdir/bionic $STLPORT_CPPFLAGS $CPPFLAGS"
CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS"
LIBS="$LIBS $STLPORT_LIBS"
dnl Add -llog by default, since we use it all over the place.
LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ -llog $LDFLAGS"
dnl prevent cross compile section from using these flags as host flags
if test -z "$HOST_CPPFLAGS" ; then
HOST_CPPFLAGS=" "
fi
if test -z "$HOST_CFLAGS" ; then
HOST_CFLAGS=" "
fi
if test -z "$HOST_CXXFLAGS" ; then
HOST_CXXFLAGS=" "
fi
if test -z "$HOST_LDFLAGS" ; then
HOST_LDFLAGS=" "
fi
# save these for libffi's subconfigure,
# which doesn't know how to figure this stuff out on its own
ANDROID_CFLAGS="$CFLAGS"
ANDROID_CPPFLAGS="$CPPFLAGS"
ANDROID_LDFLAGS="$LDFLAGS"
AC_DEFINE(ANDROID)
AC_DEFINE(GONK)
CROSS_COMPILE=1
else
case "$target" in
*-android*|*-linuxandroid*)
if test -z "$android_ndk" ; then
@ -403,6 +457,8 @@ case "$target" in
;;
esac
fi
AC_SUBST(ANDROID_NDK)
AC_SUBST(ANDROID_TOOLCHAIN)
AC_SUBST(ANDROID_PLATFORM)

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

@ -1601,7 +1601,7 @@ JSContext::purge()
static bool
ComputeIsJITBroken()
{
#ifndef ANDROID
#if !defined(ANDROID) || defined(GONK)
return false;
#else // ANDROID
if (getenv("JS_IGNORE_JIT_BROKENNESS")) {

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

@ -147,7 +147,7 @@ using mozilla::dom::indexedDB::IndexedDatabaseManager;
#include "nsNullPrincipal.h"
#include "nsNetCID.h"
#include "nsINodeInfo.h"
#if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_PLATFORM_MAEMO)
#include "nsHapticFeedback.h"
#endif
@ -276,12 +276,14 @@ static void Shutdown();
#endif
#include "nsGeolocation.h"
#ifndef MOZ_WIDGET_GONK
#if defined(XP_UNIX) || \
defined(_WINDOWS) || \
defined(machintosh) || \
defined(android)
#include "nsDeviceMotionSystem.h"
#endif
#endif
#include "nsCSPService.h"
// Transformiix
@ -309,16 +311,18 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDOMStorageManager,
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChannelPolicy)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(IndexedDatabaseManager,
IndexedDatabaseManager::FactoryCreate)
#ifndef MOZ_WIDGET_GONK
#if defined(XP_UNIX) || \
defined(_WINDOWS) || \
defined(machintosh) || \
defined(android)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceMotionSystem)
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init)
#if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback)
#endif
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init)
//-----------------------------------------------------------------------------
@ -836,6 +840,7 @@ NS_DEFINE_NAMED_CID(NS_SECURITYNAMESET_CID);
NS_DEFINE_NAMED_CID(THIRDPARTYUTIL_CID);
NS_DEFINE_NAMED_CID(NS_STRUCTUREDCLONECONTAINER_CID);
#ifndef MOZ_WIDGET_GONK
#if defined(XP_UNIX) || \
defined(_WINDOWS) || \
defined(machintosh) || \
@ -845,6 +850,7 @@ NS_DEFINE_NAMED_CID(NS_DEVICE_MOTION_CID);
#if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID);
#endif
#endif
static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
XPCONNECT_CIDENTRIES
@ -965,6 +971,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_SYSTEMPRINCIPAL_CID, false, NULL, nsSystemPrincipalConstructor },
{ &kNS_NULLPRINCIPAL_CID, false, NULL, nsNullPrincipalConstructor },
{ &kNS_SECURITYNAMESET_CID, false, NULL, nsSecurityNameSetConstructor },
#ifndef MOZ_WIDGET_GONK
#if defined(XP_UNIX) || \
defined(_WINDOWS) || \
defined(machintosh) || \
@ -973,6 +980,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
#endif
#if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
{ &kNS_HAPTICFEEDBACK_CID, false, NULL, nsHapticFeedbackConstructor },
#endif
#endif
{ &kTHIRDPARTYUTIL_CID, false, NULL, ThirdPartyUtilConstructor },
{ &kNS_STRUCTUREDCLONECONTAINER_CID, false, NULL, nsStructuredCloneContainerConstructor },
@ -1092,6 +1100,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ NS_SYSTEMPRINCIPAL_CONTRACTID, &kNS_SYSTEMPRINCIPAL_CID },
{ NS_NULLPRINCIPAL_CONTRACTID, &kNS_NULLPRINCIPAL_CID },
{ NS_SECURITYNAMESET_CONTRACTID, &kNS_SECURITYNAMESET_CID },
#ifndef MOZ_WIDGET_GONK
#if defined(XP_UNIX) || \
defined(_WINDOWS) || \
defined(machintosh) || \
@ -1100,6 +1109,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
#endif
#if defined(ANDROID) || defined(MOZ_PLATFORM_MAEMO)
{ "@mozilla.org/widget/hapticfeedback;1", &kNS_HAPTICFEEDBACK_CID },
#endif
#endif
{ THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID },
{ NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID },

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

@ -1705,7 +1705,7 @@ nsObjectFrame::PaintPlugin(nsDisplayListBuilder* aBuilder,
nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect, const nsRect& aPluginRect)
{
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
if (mInstanceOwner) {
NPWindow *window;
mInstanceOwner->GetWindow(window);

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

@ -51,7 +51,11 @@ CSRCS = \
$(NULL)
endif
ifeq ($(OS_TARGET),Android)
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
CSRCS = \
sydney_audio_gonk.c \
$(NULL)
else ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CSRCS = \
sydney_audio_android.c \
$(NULL)

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

@ -0,0 +1,315 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* CSIRO
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Michael Martin
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** *
*/
#include <stdlib.h>
#include <time.h>
#include "sydney_audio.h"
#include "android/log.h"
#ifndef ALOG
#if defined(DEBUG) || defined(FORCE_ALOG)
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gecko - SYDNEY_AUDIO" , ## args)
#else
#define ALOG(args...)
#endif
#endif
/* Gonk implementation based on sydney_audio_mac.c */
/* XXX This is temporary until we figure out a way to hook ALSA up */
#define NANOSECONDS_IN_MILLISECOND 1000000
#define MILLISECONDS_PER_SECOND 1000
struct sa_stream {
unsigned int rate;
unsigned int channels;
unsigned int isPaused;
int64_t lastStartTime;
int64_t timePlaying;
int64_t amountWritten;
unsigned int bufferSize;
};
/*
* -----------------------------------------------------------------------------
* Startup and shutdown functions
* -----------------------------------------------------------------------------
*/
int
sa_stream_create_pcm(
sa_stream_t ** _s,
const char * client_name,
sa_mode_t mode,
sa_pcm_format_t format,
unsigned int rate,
unsigned int channels
) {
/*
* Make sure we return a NULL stream pointer on failure.
*/
if (_s == NULL) {
return SA_ERROR_INVALID;
}
*_s = NULL;
if (mode != SA_MODE_WRONLY) {
return SA_ERROR_NOT_SUPPORTED;
}
if (format != SA_PCM_FORMAT_S16_NE) {
return SA_ERROR_NOT_SUPPORTED;
}
if (channels != 1 && channels != 2) {
return SA_ERROR_NOT_SUPPORTED;
}
/*
* Allocate the instance and required resources.
*/
sa_stream_t *s;
if ((s = malloc(sizeof(sa_stream_t))) == NULL) {
return SA_ERROR_OOM;
}
s->rate = rate;
s->channels = channels;
s->isPaused = 0;
s->lastStartTime = 0;
s->timePlaying = 0;
s->amountWritten = 0;
s->bufferSize = rate * channels;
*_s = s;
return SA_SUCCESS;
}
int
sa_stream_open(sa_stream_t *s) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
return SA_ERROR_NO_DEVICE;
}
int
sa_stream_destroy(sa_stream_t *s) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
/*
* -----------------------------------------------------------------------------
* Data read and write functions
* -----------------------------------------------------------------------------
*/
int
sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
if (nbytes == 0) {
return SA_SUCCESS;
}
// XXX
return SA_SUCCESS;
}
/*
* -----------------------------------------------------------------------------
* General query and support functions
* -----------------------------------------------------------------------------
*/
int
sa_stream_get_write_size(sa_stream_t *s, size_t *size) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
int
sa_stream_get_position(sa_stream_t *s, sa_position_t position, int64_t *pos) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
int
sa_stream_pause(sa_stream_t *s) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
int
sa_stream_resume(sa_stream_t *s) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
int
sa_stream_drain(sa_stream_t *s)
{
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
/*
* -----------------------------------------------------------------------------
* Extension functions
* -----------------------------------------------------------------------------
*/
int
sa_stream_set_volume_abs(sa_stream_t *s, float vol) {
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
// XXX
return SA_SUCCESS;
}
/*
* -----------------------------------------------------------------------------
* Unsupported functions
* -----------------------------------------------------------------------------
*/
#define UNSUPPORTED(func) func { return SA_ERROR_NOT_SUPPORTED; }
UNSUPPORTED(int sa_stream_create_opaque(sa_stream_t **s, const char *client_name, sa_mode_t mode, const char *codec))
UNSUPPORTED(int sa_stream_set_write_lower_watermark(sa_stream_t *s, size_t size))
UNSUPPORTED(int sa_stream_set_read_lower_watermark(sa_stream_t *s, size_t size))
UNSUPPORTED(int sa_stream_set_write_upper_watermark(sa_stream_t *s, size_t size))
UNSUPPORTED(int sa_stream_set_read_upper_watermark(sa_stream_t *s, size_t size))
UNSUPPORTED(int sa_stream_set_channel_map(sa_stream_t *s, const sa_channel_t map[], unsigned int n))
UNSUPPORTED(int sa_stream_set_xrun_mode(sa_stream_t *s, sa_xrun_mode_t mode))
UNSUPPORTED(int sa_stream_set_non_interleaved(sa_stream_t *s, int enable))
UNSUPPORTED(int sa_stream_set_dynamic_rate(sa_stream_t *s, int enable))
UNSUPPORTED(int sa_stream_set_driver(sa_stream_t *s, const char *driver))
UNSUPPORTED(int sa_stream_start_thread(sa_stream_t *s, sa_event_callback_t callback))
UNSUPPORTED(int sa_stream_stop_thread(sa_stream_t *s))
UNSUPPORTED(int sa_stream_change_device(sa_stream_t *s, const char *device_name))
UNSUPPORTED(int sa_stream_change_read_volume(sa_stream_t *s, const int32_t vol[], unsigned int n))
UNSUPPORTED(int sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned int n))
UNSUPPORTED(int sa_stream_change_rate(sa_stream_t *s, unsigned int rate))
UNSUPPORTED(int sa_stream_change_meta_data(sa_stream_t *s, const char *name, const void *data, size_t size))
UNSUPPORTED(int sa_stream_change_user_data(sa_stream_t *s, const void *value))
UNSUPPORTED(int sa_stream_set_adjust_rate(sa_stream_t *s, sa_adjust_t direction))
UNSUPPORTED(int sa_stream_set_adjust_nchannels(sa_stream_t *s, sa_adjust_t direction))
UNSUPPORTED(int sa_stream_set_adjust_pcm_format(sa_stream_t *s, sa_adjust_t direction))
UNSUPPORTED(int sa_stream_set_adjust_watermarks(sa_stream_t *s, sa_adjust_t direction))
UNSUPPORTED(int sa_stream_get_mode(sa_stream_t *s, sa_mode_t *access_mode))
UNSUPPORTED(int sa_stream_get_codec(sa_stream_t *s, char *codec, size_t *size))
UNSUPPORTED(int sa_stream_get_pcm_format(sa_stream_t *s, sa_pcm_format_t *format))
UNSUPPORTED(int sa_stream_get_rate(sa_stream_t *s, unsigned int *rate))
UNSUPPORTED(int sa_stream_get_nchannels(sa_stream_t *s, int *nchannels))
UNSUPPORTED(int sa_stream_get_user_data(sa_stream_t *s, void **value))
UNSUPPORTED(int sa_stream_get_write_lower_watermark(sa_stream_t *s, size_t *size))
UNSUPPORTED(int sa_stream_get_read_lower_watermark(sa_stream_t *s, size_t *size))
UNSUPPORTED(int sa_stream_get_write_upper_watermark(sa_stream_t *s, size_t *size))
UNSUPPORTED(int sa_stream_get_read_upper_watermark(sa_stream_t *s, size_t *size))
UNSUPPORTED(int sa_stream_get_channel_map(sa_stream_t *s, sa_channel_t map[], unsigned int *n))
UNSUPPORTED(int sa_stream_get_xrun_mode(sa_stream_t *s, sa_xrun_mode_t *mode))
UNSUPPORTED(int sa_stream_get_non_interleaved(sa_stream_t *s, int *enabled))
UNSUPPORTED(int sa_stream_get_dynamic_rate(sa_stream_t *s, int *enabled))
UNSUPPORTED(int sa_stream_get_driver(sa_stream_t *s, char *driver_name, size_t *size))
UNSUPPORTED(int sa_stream_get_device(sa_stream_t *s, char *device_name, size_t *size))
UNSUPPORTED(int sa_stream_get_read_volume(sa_stream_t *s, int32_t vol[], unsigned int *n))
UNSUPPORTED(int sa_stream_get_write_volume(sa_stream_t *s, int32_t vol[], unsigned int *n))
UNSUPPORTED(int sa_stream_get_meta_data(sa_stream_t *s, const char *name, void*data, size_t *size))
UNSUPPORTED(int sa_stream_get_adjust_rate(sa_stream_t *s, sa_adjust_t *direction))
UNSUPPORTED(int sa_stream_get_adjust_nchannels(sa_stream_t *s, sa_adjust_t *direction))
UNSUPPORTED(int sa_stream_get_adjust_pcm_format(sa_stream_t *s, sa_adjust_t *direction))
UNSUPPORTED(int sa_stream_get_adjust_watermarks(sa_stream_t *s, sa_adjust_t *direction))
UNSUPPORTED(int sa_stream_get_state(sa_stream_t *s, sa_state_t *state))
UNSUPPORTED(int sa_stream_get_event_error(sa_stream_t *s, sa_error_t *error))
UNSUPPORTED(int sa_stream_get_event_notify(sa_stream_t *s, sa_notify_t *notify))
UNSUPPORTED(int sa_stream_read(sa_stream_t *s, void *data, size_t nbytes))
UNSUPPORTED(int sa_stream_read_ni(sa_stream_t *s, unsigned int channel, void *data, size_t nbytes))
UNSUPPORTED(int sa_stream_write_ni(sa_stream_t *s, unsigned int channel, const void *data, size_t nbytes))
UNSUPPORTED(int sa_stream_pwrite(sa_stream_t *s, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence))
UNSUPPORTED(int sa_stream_pwrite_ni(sa_stream_t *s, unsigned int channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence))
UNSUPPORTED(int sa_stream_get_read_size(sa_stream_t *s, size_t *size))
UNSUPPORTED(int sa_stream_get_volume_abs(sa_stream_t *s, float *vol))
UNSUPPORTED(int sa_stream_get_min_write(sa_stream_t *s, size_t *size))
const char *sa_strerror(int code) { return NULL; }

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

@ -51,9 +51,14 @@ endif
MODULE = mozalloc
LIBRARY_NAME = mozalloc
FORCE_SHARED_LIB= 1
DIST_INSTALL = 1
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
FORCE_STATIC_LIB= 1
else
FORCE_SHARED_LIB= 1
endif
ifeq (,$(filter-out OS2,$(OS_ARCH)))
# The strndup declaration in string.h is in an ifdef __USE_GNU section
DEFINES += -D_GNU_SOURCE

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

@ -80,10 +80,13 @@ NO_INSTALL_IMPORT_LIBRARY = 1
endif
endif
ifeq (Android, $(OS_TARGET))
ifeq (android, $(MOZ_WIDGET_TOOLKIT))
# Add Android linker
EXTRA_DSO_LDOPTS += $(ZLIB_LIBS)
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android)
endif
ifeq (Android, $(OS_TARGET))
WRAP_LDFLAGS =
endif

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

@ -48,7 +48,7 @@
#include <QtGui/QWidget>
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -92,7 +92,7 @@ nsShellService::CreateShortcut(const nsAString& aTitle, const nsAString& aURI, c
if (!aTitle.Length() || !aURI.Length() || !aIconData.Length())
return NS_ERROR_FAILURE;
#if ANDROID
#if MOZ_WIDGET_ANDROID
mozilla::AndroidBridge::Bridge()->CreateShortcut(aTitle, aURI, aIconData, aIntent);
return NS_OK;
#else

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

@ -364,7 +364,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMaemoNetworkLinkService, Init)
#elif defined(MOZ_ENABLE_QTNETWORK)
#include "nsQtNetworkLinkService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsQtNetworkLinkService, Init)
#elif defined(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
#include "nsAndroidNetworkLinkService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroidNetworkLinkService)
#endif
@ -801,7 +801,7 @@ NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
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(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
NS_DEFINE_NAMED_CID(NS_NETWORK_LINK_SERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(NS_SERIALIZATION_HELPER_CID);
@ -934,7 +934,7 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
{ &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsMaemoNetworkLinkServiceConstructor },
#elif defined(MOZ_ENABLE_QTNETWORK)
{ &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsQtNetworkLinkServiceConstructor },
#elif defined(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
{ &kNS_NETWORK_LINK_SERVICE_CID, false, NULL, nsAndroidNetworkLinkServiceConstructor },
#endif
{ &kNS_SERIALIZATION_HELPER_CID, false, NULL, nsSerializationHelperConstructor },
@ -1072,7 +1072,7 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
{ 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(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
{ NS_NETWORK_LINK_SERVICE_CONTRACTID, &kNS_NETWORK_LINK_SERVICE_CID },
#endif
{ NS_SERIALIZATION_HELPER_CONTRACTID, &kNS_SERIALIZATION_HELPER_CID },

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

@ -51,7 +51,7 @@ CPPSRCS = \
nsDeviceProtocolHandler.cpp \
$(NULL)
ifeq (Android,$(OS_TARGET))
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += AndroidCaptureProvider.cpp \
CameraStreamImpl.cpp \
$(NULL)

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

@ -41,7 +41,7 @@
#include "nsDeviceCaptureProvider.h"
#include "mozilla/Preferences.h"
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidCaptureProvider.h"
#endif
@ -140,7 +140,7 @@ nsDeviceChannel::OpenContentStream(bool aAsync,
if (!captureParams.height)
captureParams.height = 480;
captureParams.bpp = 32;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
capture = GetAndroidCaptureProvider();
#endif
} else if (kNotFound != spec.Find(NS_LITERAL_CSTRING("type=video/x-raw-yuv"),
@ -164,7 +164,7 @@ nsDeviceChannel::OpenContentStream(bool aAsync,
captureParams.bpp = 32;
captureParams.timeLimit = 0;
captureParams.frameLimit = 60000;
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
// only enable if "device.camera.enabled" is true.
if (mozilla::Preferences::GetBool("device.camera.enabled", false) == true)
capture = GetAndroidCaptureProvider();

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

@ -260,8 +260,14 @@ DEFAULT_GMAKE_FLAGS += \
OS_RELEASE="2.6" \
OS_PTHREAD= \
STANDARDS_CFLAGS="-std=gnu89" \
ARCHFLAG="$(CFLAGS) -DCHECK_FORK_GETPID -DRTLD_NOLOAD=0 -DANDROID_VERSION=$(ANDROID_VERSION) -include $(ABS_topsrcdir)/security/manager/android_stub.h" \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
DEFAULT_GMAKE_FLAGS += ARCHFLAG="$(CFLAGS) -DCHECK_FORK_GETPID -DRTLD_NOLOAD=0 -DANDROID_VERSION=$(ANDROID_VERSION) -include $(ABS_topsrcdir)/security/manager/android_stub.h"
else
DEFAULT_GMAKE_FLAGS += ARCHFLAG="$(CFLAGS) -DCHECK_FORK_GETPID -DRTLD_NOLOAD=0 -include $(ABS_topsrcdir)/security/manager/android_stub.h"
endif
endif
endif

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

@ -41,6 +41,7 @@
#define ANDROID_STUB_H
#include "dlfcn.h"
#ifdef ANDROID_VERSION
#if ANDROID_VERSION < 8
/* because dladdr isn't supported in android 2.1 and older.
* however, it exists in the android repos so.. maybe someday. */
@ -50,6 +51,7 @@ typedef struct {
#define dladdr(foo, bar) 0
#endif
#endif
/* sysinfo is defined but not implemented.
* we may be able to implement it ourselves. */

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

@ -83,7 +83,7 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -1178,7 +1178,7 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsILocalFile **aResult)
rv = dirService->Get(NS_UNIX_XDG_DOCUMENTS_DIR,
NS_GET_IID(nsILocalFile),
getter_AddRefs(downloadDir));
#elif defined(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
// Android doesn't have a $HOME directory, and by default we only have
// write access to /data/data/org.mozilla.{$APP} and /sdcard
char* downloadDirPath = getenv("DOWNLOADS_DIRECTORY");
@ -2254,7 +2254,7 @@ nsDownload::SetState(DownloadState aState)
}
}
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(ANDROID)
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget);
nsCOMPtr<nsIFile> file;
nsAutoString path;
@ -2288,7 +2288,7 @@ nsDownload::SetState(DownloadState aState)
observedObject, NULL, TRUE);
::CFRelease(observedObject);
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
nsCOMPtr<nsIMIMEInfo> mimeInfo;
nsCAutoString contentType;
GetMIMEInfo(getter_AddRefs(mimeInfo));

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

@ -217,7 +217,7 @@ COMPONENT_LIBS += universalchardet
DEFINES += -DMOZ_UNIVERSALCHARDET
endif
ifeq (,$(filter android qt os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
ifeq (,$(filter android gonk qt os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
ifdef MOZ_XUL
COMPONENT_LIBS += fileview
DEFINES += -DMOZ_FILEVIEW
@ -261,6 +261,10 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),android)
COMPONENT_LIBS += widget_android
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
COMPONENT_LIBS += widget_gonk
endif
STATIC_LIBS += thebes ycbcr
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
@ -365,3 +369,7 @@ endif
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
OS_LIBS += -lGLESv2
endif
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
OS_LIBS += -lui
endif

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

@ -77,6 +77,8 @@
# define WIDGET_MODULES MODULE(nsWidgetQtModule)
#elif defined(MOZ_WIDGET_ANDROID)
# define WIDGET_MODULES MODULE(nsWidgetAndroidModule)
#elif defined(MOZ_WIDGET_GONK)
# define WIDGET_MODULES MODULE(nsWidgetGonkModule)
#else
# error Unknown widget module.
#endif

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

@ -56,7 +56,7 @@ else
ifeq (,$(filter-out gtk2 qt, $(MOZ_WIDGET_TOOLKIT)))
MOZ_PKG_FORMAT = BZ2
else
ifeq (Android,$(OS_TARGET))
ifeq (android,$(MOZ_WIDGET_TOOLKIT))
MOZ_PKG_FORMAT = APK
else
MOZ_PKG_FORMAT = TGZ

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

@ -128,7 +128,7 @@ ifdef MOZ_X11
CPPSRCS += nsX11ErrorHandler.cpp
endif
ifeq ($(OS_TARGET),Android)
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
CPPSRCS += nsAndroidStartup.cpp
DEFINES += -DANDROID_PACKAGE_NAME='"$(ANDROID_PACKAGE_NAME)"'
endif

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

@ -217,7 +217,7 @@ using mozilla::unused;
#include "mozilla/FunctionTimer.h"
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -1607,7 +1607,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
SaveToEnv("MOZ_LAUNCHED_CHILD=1");
#if defined(ANDROID)
#if defined(MOZ_WIDGET_ANDROID)
mozilla::AndroidBridge::Bridge()->ScheduleRestart();
#else
#if defined(XP_MACOSX)
@ -1658,7 +1658,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
#endif // XP_OS2 series
#endif // WP_WIN
#endif // WP_MACOSX
#endif // ANDROID
#endif // MOZ_WIDGET_ANDROID
return NS_ERROR_LAUNCHED_CHILD_PROCESS;
}

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

@ -1065,6 +1065,9 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsILocalFile** aFile, bool aLocal)
*strrchr(appDir, '\\') = '\0';
rv = NS_NewNativeLocalFile(nsDependentCString(appDir), true, getter_AddRefs(localDir));
}
#elif defined(MOZ_WIDGET_GONK)
rv = NS_NewNativeLocalFile(NS_LITERAL_CSTRING("/data/b2g"), PR_TRUE,
getter_AddRefs(localDir));
#elif defined(XP_UNIX)
const char* homeDir = getenv("HOME");
if (!homeDir || !*homeDir)

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

@ -60,11 +60,15 @@ else
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
OSDIR = android
else
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
OSDIR = gonk
else
OSDIR = unix
endif
endif
endif
endif
endif
VPATH := $(srcdir) $(srcdir)/$(OSDIR)

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

@ -0,0 +1,63 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Gonk code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsOSHelperAppService.h"
nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService()
{
}
nsOSHelperAppService::~nsOSHelperAppService()
{
}
already_AddRefed<nsIMIMEInfo>
nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
const nsACString& aFileExt,
bool* aFound)
{
*aFound = false;
return nsnull;
}
nsresult
nsOSHelperAppService::OSProtocolHandlerExists(const char* aScheme,
bool* aExists)
{
*aExists = false;
return NS_OK;
}

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

@ -0,0 +1,60 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Gonk code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsOSHelperAppService_h
#define nsOSHelperAppService_h
#include "nsCExternalHandlerService.h"
#include "nsExternalHelperAppService.h"
class nsOSHelperAppService : public nsExternalHelperAppService
{
public:
nsOSHelperAppService();
virtual ~nsOSHelperAppService();
virtual already_AddRefed<nsIMIMEInfo>
GetMIMEInfoFromOS(const nsACString& aMIMEType,
const nsACString& aFileExt,
bool* aFound);
virtual NS_HIDDEN_(nsresult)
OSProtocolHandlerExists(const char* aScheme,
bool* aExists);
};
#endif /* nsOSHelperAppService_h */

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

@ -147,7 +147,7 @@
#include "nsIDocShellTreeItem.h"
#include "ExternalHelperAppChild.h"
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -485,7 +485,7 @@ static nsExtraMimeTypeEntry extraMimeEntries [] =
{ APPLICATION_XPINSTALL, "xpi", "XPInstall Install" },
{ APPLICATION_POSTSCRIPT, "ps,eps,ai", "Postscript File" },
{ APPLICATION_XJAVASCRIPT, "js", "Javascript Source File" },
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
{ "application/vnd.android.package-archive", "apk", "Android Package" },
#endif
{ IMAGE_ART, "art", "ART Image" },

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

@ -88,7 +88,7 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
EXPORTS += nsIDragSessionOS2.h
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),android)
ifneq (,$(filter android gonk,$(MOZ_WIDGET_TOOLKIT)))
EXPORTS += \
nsIPrintDialogService.h \
$(NULL)

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

@ -46,7 +46,7 @@ MODULE = widget
DIRS = shared xpwidgets
ifneq (,$(filter os2 cocoa qt android,$(MOZ_WIDGET_TOOLKIT)))
ifneq (,$(filter os2 cocoa qt android gonk,$(MOZ_WIDGET_TOOLKIT)))
DIRS += $(MOZ_WIDGET_TOOLKIT)
endif

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

@ -0,0 +1,75 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (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.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation
# Portions created by the Initial Developer are Copyright (C) 2009-2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Vladimir Vukicevic <vladimir@pobox.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = widget
LIBRARY_NAME = widget_gonk
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsWidgetGonkModule
GRE_MODULE = 1
LIBXUL_LIBRARY = 1
CPPSRCS = \
nsAppShell.cpp \
nsWidgetFactory.cpp \
nsWindow.cpp \
nsLookAndFeel.cpp \
nsScreenManagerGonk.cpp \
$(NULL)
SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_WIDGET
LOCAL_INCLUDES += \
-I$(topsrcdir)/widget/src/xpwidgets \
-I$(topsrcdir)/widget/src/shared \
-I$(topsrcdir)/dom/system/android \
-I$(srcdir) \
$(NULL)
include $(topsrcdir)/ipc/chromium/chromium-config.mk

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

@ -0,0 +1,473 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 sw=4 sts=4 tw=80 et: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Gonk.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#define _GNU_SOURCE
#include <dirent.h>
#include <fcntl.h>
#include <linux/input.h>
#include <signal.h>
#include <sys/epoll.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include "nsAppShell.h"
#include "nsGkAtoms.h"
#include "nsGUIEvent.h"
#include "nsWindow.h"
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "android/log.h"
#ifndef ABS_MT_TOUCH_MAJOR
// Taken from include/linux/input.h
// XXX update the bionic input.h so we don't have to do this!
#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */
#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
#define SYN_MT_REPORT 2
#endif
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
using namespace mozilla;
bool gDrawRequest = false;
static nsAppShell *gAppShell = NULL;
static int epollfd = 0;
static int signalfds[2] = {0};
namespace mozilla {
bool ProcessNextEvent()
{
return gAppShell->ProcessNextNativeEvent(true);
}
void NotifyEvent()
{
gAppShell->NotifyNativeEvent();
}
}
static void
pipeHandler(int fd, FdHandler *data)
{
ssize_t len;
do {
char tmp[32];
len = read(fd, tmp, sizeof(tmp));
} while (len > 0);
}
static
PRUint64 timevalToMS(const struct timeval &time)
{
return time.tv_sec * 1000 + time.tv_usec / 1000;
}
static void
sendMouseEvent(PRUint32 msg, struct timeval *time, int x, int y)
{
nsMouseEvent event(true, msg, NULL,
nsMouseEvent::eReal, nsMouseEvent::eNormal);
event.refPoint.x = x;
event.refPoint.y = y;
event.time = timevalToMS(*time);
event.isShift = false;
event.isControl = false;
event.isMeta = false;
event.isAlt = false;
event.button = nsMouseEvent::eLeftButton;
if (msg != NS_MOUSE_MOVE)
event.clickCount = 1;
nsWindow::DispatchInputEvent(event);
//LOG("Dispatched type %d at %dx%d", msg, x, y);
}
static void
multitouchHandler(int fd, FdHandler *data)
{
// The Linux's input documentation (Documentation/input/input.txt)
// says that we'll always read a multiple of sizeof(input_event) bytes here.
input_event events[16];
int event_count = read(fd, events, sizeof(events));
if (event_count < 0) {
LOG("Error reading in multitouchHandler");
return;
}
MOZ_ASSERT(event_count % sizeof(input_event) == 0);
event_count /= sizeof(struct input_event);
for (int i = 0; i < event_count; i++) {
input_event *event = &events[i];
if (event->type == EV_ABS) {
if (data->mtState == FdHandler::MT_IGNORE)
continue;
if (data->mtState == FdHandler::MT_START)
data->mtState = FdHandler::MT_COLLECT;
switch (event->code) {
case ABS_MT_TOUCH_MAJOR:
data->mtMajor = event->value;
break;
case ABS_MT_TOUCH_MINOR:
case ABS_MT_WIDTH_MAJOR:
case ABS_MT_WIDTH_MINOR:
case ABS_MT_ORIENTATION:
case ABS_MT_TOOL_TYPE:
case ABS_MT_BLOB_ID:
case ABS_MT_TRACKING_ID:
case ABS_MT_PRESSURE:
break;
case ABS_MT_POSITION_X:
data->mtX = event->value;
break;
case ABS_MT_POSITION_Y:
data->mtY = event->value;
break;
default:
LOG("Got unknown event type 0x%04x with code 0x%04x and value %d",
event->type, event->code, event->value);
}
} else if (event->type == EV_SYN) {
switch (event->code) {
case SYN_MT_REPORT:
if (data->mtState == FdHandler::MT_COLLECT)
data->mtState = FdHandler::MT_IGNORE;
break;
case SYN_REPORT:
if ((!data->mtMajor || data->mtState == FdHandler::MT_START)) {
sendMouseEvent(NS_MOUSE_BUTTON_UP, &event->time,
data->mtX, data->mtY);
data->mtDown = false;
//LOG("Up mouse event");
} else if (!data->mtDown) {
sendMouseEvent(NS_MOUSE_BUTTON_DOWN, &event->time,
data->mtX, data->mtY);
data->mtDown = true;
//LOG("Down mouse event");
} else {
sendMouseEvent(NS_MOUSE_MOVE, &event->time,
data->mtX, data->mtY);
data->mtDown = true;
}
data->mtState = FdHandler::MT_START;
break;
default:
LOG("Got unknown event type 0x%04x with code 0x%04x and value %d",
event->type, event->code, event->value);
}
} else
LOG("Got unknown event type 0x%04x with code 0x%04x and value %d",
event->type, event->code, event->value);
}
}
static void
sendKeyEventWithMsg(PRUint32 keyCode, PRUint32 msg, const struct timeval &time)
{
nsKeyEvent event(true, msg, NULL);
event.keyCode = keyCode;
event.time = timevalToMS(time);
nsWindow::DispatchInputEvent(event);
}
static void
sendKeyEvent(PRUint32 keyCode, bool keyDown, const struct timeval &time)
{
sendKeyEventWithMsg(keyCode, keyDown ? NS_KEY_DOWN : NS_KEY_UP, time);
if (keyDown) {
// Send a key press event right after the key down event.
sendKeyEventWithMsg(keyCode, NS_KEY_PRESS, time);
}
}
static void
sendSpecialKeyEvent(nsIAtom *command, const struct timeval &time)
{
nsCommandEvent event(true, nsGkAtoms::onAppCommand, command, NULL);
event.time = timevalToMS(time);
nsWindow::DispatchInputEvent(event);
}
static int screenFd = -1;
static bool sScreenOn = true;
static void
handlePowerKeyPressed()
{
if (screenFd == -1) {
screenFd = open("/sys/power/state", O_RDWR);
if (screenFd < 0) {
LOG("Unable to open /sys/power/state.");
return;
}
}
// No idea why the screen-off string is "mem" rather than "off".
const char *state = sScreenOn ? "mem" : "on";
if (write(screenFd, state, strlen(state)) < 0) {
LOG("Unable to write to /sys/power/state.");
return;
}
sScreenOn = !sScreenOn;
}
static void
keyHandler(int fd, FdHandler *data)
{
input_event events[16];
ssize_t bytesRead = read(fd, events, sizeof(events));
if (bytesRead < 0) {
LOG("Error reading in keyHandler");
return;
}
MOZ_ASSERT(bytesRead % sizeof(input_event) == 0);
for (unsigned int i = 0; i < bytesRead / sizeof(struct input_event); i++) {
const input_event &e = events[i];
if (e.type == EV_SYN) {
// Ignore this event; it just signifies that a key was pressed.
continue;
}
if (e.type != EV_KEY) {
LOG("Got unknown key event type. type 0x%04x code 0x%04x value %d",
e.type, e.code, e.value);
continue;
}
if (e.value != 0 && e.value != 1) {
LOG("Got unknown key event value. type 0x%04x code 0x%04x value %d",
e.type, e.code, e.value);
continue;
}
if (!sScreenOn && e.code != KEY_POWER) {
LOG("Ignoring key event, because the screen is off. "
"type 0x%04x code 0x%04x value %d",
e.type, e.code, e.value);
continue;
}
bool pressed = e.value == 1;
const char* upOrDown = pressed ? "pressed" : "released";
switch (e.code) {
case KEY_BACK:
sendKeyEvent(NS_VK_ESCAPE, pressed, e.time);
break;
case KEY_MENU:
if (!pressed)
sendSpecialKeyEvent(nsGkAtoms::Menu, e.time);
break;
case KEY_SEARCH:
if (pressed)
sendSpecialKeyEvent(nsGkAtoms::Search, e.time);
break;
case KEY_HOME:
sendKeyEvent(NS_VK_HOME, pressed, e.time);
break;
case KEY_POWER:
LOG("Power key %s", upOrDown);
// Ideally, we'd send a NS_VK_SLEEP event here and let the front-end
// sort out what to do. But for now, let's just turn off the screen
// ourselves.
if (pressed)
handlePowerKeyPressed();
break;
case KEY_VOLUMEUP:
if (pressed)
sendSpecialKeyEvent(nsGkAtoms::VolumeUp, e.time);
break;
case KEY_VOLUMEDOWN:
if (pressed)
sendSpecialKeyEvent(nsGkAtoms::VolumeDown, e.time);
break;
default:
LOG("Got unknown key event code. type 0x%04x code 0x%04x value %d",
e.type, e.code, e.value);
}
}
}
nsAppShell::nsAppShell()
: mNativeCallbackRequest(false)
, mHandlers()
{
gAppShell = this;
}
nsAppShell::~nsAppShell()
{
gAppShell = NULL;
}
nsresult
nsAppShell::Init()
{
epoll_event event = {
EPOLLIN,
{ 0 }
};
nsresult rv = nsBaseAppShell::Init();
NS_ENSURE_SUCCESS(rv, rv);
epollfd = epoll_create(16);
NS_ENSURE_TRUE(epollfd >= 0, NS_ERROR_UNEXPECTED);
int ret = pipe2(signalfds, O_NONBLOCK);
NS_ENSURE_FALSE(ret, NS_ERROR_UNEXPECTED);
FdHandler *handler = mHandlers.AppendElement();
handler->fd = signalfds[0];
handler->func = pipeHandler;
event.data.u32 = mHandlers.Length() - 1;
ret = epoll_ctl(epollfd, EPOLL_CTL_ADD, signalfds[0], &event);
NS_ENSURE_FALSE(ret, NS_ERROR_UNEXPECTED);
DIR *dir = opendir("/dev/input");
NS_ENSURE_TRUE(dir, NS_ERROR_UNEXPECTED);
#define BITSET(bit, flags) (flags[bit >> 3] & (1 << (bit & 0x7)))
struct dirent *entry;
while ((entry = readdir(dir))) {
char entryName[64];
char entryPath[MAXPATHLEN];
if (snprintf(entryPath, sizeof(entryPath),
"/dev/input/%s", entry->d_name) < 0) {
LOG("Couldn't generate path while enumerating input devices!");
continue;
}
int fd = open(entryPath, O_RDONLY);
if (ioctl(fd, EVIOCGNAME(sizeof(entryName)), entryName) >= 0)
LOG("Found device %s - %s", entry->d_name, entryName);
else
continue;
FdHandlerCallback handlerFunc = NULL;
char flags[(NS_MAX(ABS_MAX, KEY_MAX) + 1) / 8];
if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(flags)), flags) >= 0 &&
BITSET(ABS_MT_POSITION_X, flags)) {
LOG("Found absolute input device");
handlerFunc = multitouchHandler;
} else if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(flags)), flags) >= 0) {
LOG("Found key input device");
handlerFunc = keyHandler;
}
// Register the handler, if we have one.
if (!handlerFunc)
continue;
handler = mHandlers.AppendElement();
handler->fd = fd;
handler->func = handlerFunc;
event.data.u32 = mHandlers.Length() - 1;
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &event))
LOG("Failed to add fd to epoll fd");
}
return rv;
}
void
nsAppShell::ScheduleNativeEventCallback()
{
mNativeCallbackRequest = true;
NotifyEvent();
}
bool
nsAppShell::ProcessNextNativeEvent(bool mayWait)
{
epoll_event events[16] = {{ 0 }};
int event_count;
if ((event_count = epoll_wait(epollfd, events, 16, mayWait ? -1 : 0)) <= 0)
return true;
for (int i = 0; i < event_count; i++)
mHandlers[events[i].data.u32].run();
// NativeEventCallback always schedules more if it needs it
// so we can coalesce these.
// See the implementation in nsBaseAppShell.cpp for more info
if (mNativeCallbackRequest) {
mNativeCallbackRequest = false;
NativeEventCallback();
}
if (gDrawRequest) {
gDrawRequest = false;
nsWindow::DoDraw();
}
return true;
}
void
nsAppShell::NotifyNativeEvent()
{
write(signalfds[1], "w", 1);
}

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

@ -0,0 +1,94 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Gonk.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAppShell_h
#define nsAppShell_h
#include "nsBaseAppShell.h"
namespace mozilla {
bool ProcessNextEvent();
void NotifyEvent();
}
extern bool gDrawRequest;
class FdHandler;
typedef void(*FdHandlerCallback)(int, FdHandler *);
class FdHandler {
public:
FdHandler() : mtState(MT_START), mtDown(false) { }
int fd;
FdHandlerCallback func;
enum mtStates {
MT_START,
MT_COLLECT,
MT_IGNORE
} mtState;
int mtX, mtY;
int mtMajor;
bool mtDown;
void run()
{
func(fd, this);
}
};
class nsAppShell : public nsBaseAppShell {
public:
nsAppShell();
nsresult Init();
virtual bool ProcessNextNativeEvent(bool maywait);
void NotifyNativeEvent();
protected:
virtual ~nsAppShell();
virtual void ScheduleNativeEventCallback();
// This is somewhat racy but is perfectly safe given how the callback works
bool mNativeCallbackRequest;
nsTArray<FdHandler> mHandlers;
};
#endif /* nsAppShell_h */

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

@ -0,0 +1,319 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLookAndFeel.h"
nsLookAndFeel::nsLookAndFeel()
: nsXPLookAndFeel()
{
}
nsLookAndFeel::~nsLookAndFeel()
{
}
nsresult
nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
{
nsresult rv = NS_OK;
#define BASE_ACTIVE_COLOR NS_RGB(0xaa,0xaa,0xaa)
#define BASE_NORMAL_COLOR NS_RGB(0xff,0xff,0xff)
#define BASE_SELECTED_COLOR NS_RGB(0xaa,0xaa,0xaa)
#define BG_ACTIVE_COLOR NS_RGB(0xff,0xff,0xff)
#define BG_INSENSITIVE_COLOR NS_RGB(0xaa,0xaa,0xaa)
#define BG_NORMAL_COLOR NS_RGB(0xff,0xff,0xff)
#define BG_PRELIGHT_COLOR NS_RGB(0xee,0xee,0xee)
#define BG_SELECTED_COLOR NS_RGB(0x99,0x99,0x99)
#define DARK_NORMAL_COLOR NS_RGB(0x88,0x88,0x88)
#define FG_INSENSITIVE_COLOR NS_RGB(0x44,0x44,0x44)
#define FG_NORMAL_COLOR NS_RGB(0x00,0x00,0x00)
#define FG_PRELIGHT_COLOR NS_RGB(0x77,0x77,0x77)
#define FG_SELECTED_COLOR NS_RGB(0xaa,0xaa,0xaa)
#define LIGHT_NORMAL_COLOR NS_RGB(0xaa,0xaa,0xaa)
#define TEXT_ACTIVE_COLOR NS_RGB(0x99,0x99,0x99)
#define TEXT_NORMAL_COLOR NS_RGB(0x00,0x00,0x00)
#define TEXT_SELECTED_COLOR NS_RGB(0x00,0x00,0x00)
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 = BASE_NORMAL_COLOR;
break;
case eColorID_WindowForeground:
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID_WidgetBackground:
aColor = BG_NORMAL_COLOR;
break;
case eColorID_WidgetForeground:
aColor = FG_NORMAL_COLOR;
break;
case eColorID_WidgetSelectBackground:
aColor = BG_SELECTED_COLOR;
break;
case eColorID_WidgetSelectForeground:
aColor = FG_SELECTED_COLOR;
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 = BASE_NORMAL_COLOR;
break;
case eColorID_TextForeground:
// not used?
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID_TextSelectBackground:
case eColorID_IMESelectedRawTextBackground:
case eColorID_IMESelectedConvertedTextBackground:
// still used
aColor = BASE_SELECTED_COLOR;
break;
case eColorID_TextSelectForeground:
case eColorID_IMESelectedRawTextForeground:
case eColorID_IMESelectedConvertedTextForeground:
// still used
aColor = TEXT_SELECTED_COLOR;
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 = NS_RGB(0xff, 0, 0);
break;
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case eColorID_activeborder:
// active window border
aColor = BG_NORMAL_COLOR;
break;
case eColorID_activecaption:
// active window caption background
aColor = BG_NORMAL_COLOR;
break;
case eColorID_appworkspace:
// MDI background color
aColor = BG_NORMAL_COLOR;
break;
case eColorID_background:
// desktop background
aColor = BG_NORMAL_COLOR;
break;
case eColorID_captiontext:
// text in active window caption, size box, and scrollbar arrow box (!)
aColor = FG_NORMAL_COLOR;
break;
case eColorID_graytext:
// disabled text in windows, menus, etc.
aColor = FG_INSENSITIVE_COLOR;
break;
case eColorID_highlight:
// background of selected item
aColor = BASE_SELECTED_COLOR;
break;
case eColorID_highlighttext:
// text of selected item
aColor = TEXT_SELECTED_COLOR;
break;
case eColorID_inactiveborder:
// inactive window border
aColor = BG_NORMAL_COLOR;
break;
case eColorID_inactivecaption:
// inactive window caption
aColor = BG_INSENSITIVE_COLOR;
break;
case eColorID_inactivecaptiontext:
// text in inactive window caption
aColor = FG_INSENSITIVE_COLOR;
break;
case eColorID_infobackground:
// tooltip background color
aColor = BG_NORMAL_COLOR;
break;
case eColorID_infotext:
// tooltip text color
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID_menu:
// menu background
aColor = BG_NORMAL_COLOR;
break;
case eColorID_menutext:
// menu text
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID_scrollbar:
// scrollbar gray area
aColor = BG_ACTIVE_COLOR;
break;
case eColorID_threedface:
case eColorID_buttonface:
// 3-D face color
aColor = BG_NORMAL_COLOR;
break;
case eColorID_buttontext:
// text on push buttons
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID_buttonhighlight:
// 3-D highlighted edge color
case eColorID_threedhighlight:
// 3-D highlighted outer edge color
aColor = LIGHT_NORMAL_COLOR;
break;
case eColorID_threedlightshadow:
// 3-D highlighted inner edge color
aColor = BG_NORMAL_COLOR;
break;
case eColorID_buttonshadow:
// 3-D shadow edge color
case eColorID_threedshadow:
// 3-D shadow inner edge color
aColor = DARK_NORMAL_COLOR;
break;
case eColorID_threeddarkshadow:
// 3-D shadow outer edge color
aColor = NS_RGB(0,0,0);
break;
case eColorID_window:
case eColorID_windowframe:
aColor = BG_NORMAL_COLOR;
break;
case eColorID_windowtext:
aColor = FG_NORMAL_COLOR;
break;
case eColorID__moz_eventreerow:
case eColorID__moz_field:
aColor = BASE_NORMAL_COLOR;
break;
case eColorID__moz_fieldtext:
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID__moz_dialog:
aColor = BG_NORMAL_COLOR;
break;
case eColorID__moz_dialogtext:
aColor = FG_NORMAL_COLOR;
break;
case eColorID__moz_dragtargetzone:
aColor = BG_SELECTED_COLOR;
break;
case eColorID__moz_buttondefault:
// default button border color
aColor = NS_RGB(0,0,0);
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 = BASE_ACTIVE_COLOR;
break;
case eColorID__moz_cellhighlighttext:
case eColorID__moz_html_cellhighlighttext:
aColor = TEXT_ACTIVE_COLOR;
break;
case eColorID__moz_menuhover:
aColor = BG_PRELIGHT_COLOR;
break;
case eColorID__moz_menuhovertext:
aColor = FG_PRELIGHT_COLOR;
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 = TEXT_NORMAL_COLOR;
break;
case eColorID__moz_combobox:
aColor = BG_NORMAL_COLOR;
break;
case eColorID__moz_menubartext:
aColor = TEXT_NORMAL_COLOR;
break;
case eColorID__moz_menubarhovertext:
aColor = FG_PRELIGHT_COLOR;
break;
default:
/* default color is BLACK */
aColor = 0;
rv = NS_ERROR_FAILURE;
break;
}
return rv;
}

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

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Lars Knoll <knoll@kde.org>
* John C. Griggs <johng@corel.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
#include "nsXPLookAndFeel.h"
class nsLookAndFeel : public nsXPLookAndFeel
{
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
protected:
virtual nsresult NativeGetColor(ColorID aID, nscolor &aColor);
};
#endif

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

@ -0,0 +1,133 @@
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerGonk.h"
#include "nsWindow.h"
using namespace mozilla;
NS_IMPL_ISUPPORTS2(nsScreenGonk, nsIScreen, nsIScreen)
nsScreenGonk::nsScreenGonk(void *nativeScreen)
{
}
nsScreenGonk::~nsScreenGonk()
{
}
NS_IMETHODIMP
nsScreenGonk::GetRect(PRInt32 *outLeft, PRInt32 *outTop,
PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = gScreenBounds.x;
*outTop = gScreenBounds.y;
*outWidth = gScreenBounds.width;
*outHeight = gScreenBounds.height;
return NS_OK;
}
NS_IMETHODIMP
nsScreenGonk::GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop,
PRInt32 *outWidth, PRInt32 *outHeight)
{
return GetRect(outLeft, outTop, outWidth, outHeight);
}
NS_IMETHODIMP
nsScreenGonk::GetPixelDepth(PRInt32 *aPixelDepth)
{
// XXX do we need to lie here about 16bpp? Or
// should we actually check and return the right thing?
*aPixelDepth = 24;
return NS_OK;
}
NS_IMETHODIMP
nsScreenGonk::GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth(aColorDepth);
}
NS_IMPL_ISUPPORTS1(nsScreenManagerGonk, nsIScreenManager)
nsScreenManagerGonk::nsScreenManagerGonk()
{
mOneScreen = new nsScreenGonk(nsnull);
}
nsScreenManagerGonk::~nsScreenManagerGonk()
{
}
NS_IMETHODIMP
nsScreenManagerGonk::GetPrimaryScreen(nsIScreen **outScreen)
{
NS_IF_ADDREF(*outScreen = mOneScreen.get());
return NS_OK;
}
NS_IMETHODIMP
nsScreenManagerGonk::ScreenForRect(PRInt32 inLeft,
PRInt32 inTop,
PRInt32 inWidth,
PRInt32 inHeight,
nsIScreen **outScreen)
{
return GetPrimaryScreen(outScreen);
}
NS_IMETHODIMP
nsScreenManagerGonk::ScreenForNativeWidget(void *aWidget, nsIScreen **outScreen)
{
return GetPrimaryScreen(outScreen);
}
NS_IMETHODIMP
nsScreenManagerGonk::GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
*aNumberOfScreens = 1;
return NS_OK;
}

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

@ -0,0 +1,71 @@
/* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerGonk_h___
#define nsScreenManagerGonk_h___
#include "nsCOMPtr.h"
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "WidgetUtils.h"
class nsScreenGonk : public nsIScreen
{
public:
nsScreenGonk(void *nativeScreen);
~nsScreenGonk();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
};
class nsScreenManagerGonk : public nsIScreenManager
{
public:
nsScreenManagerGonk();
~nsScreenManagerGonk();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
protected:
nsCOMPtr<nsIScreen> mOneScreen;
};
#endif /* nsScreenManagerGonk_h___ */

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

@ -0,0 +1,98 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2009-2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/ModuleUtils.h"
#include "nsCOMPtr.h"
#include "nsWidgetsCID.h"
#include "nsAppShell.h"
#include "nsWindow.h"
#include "nsLookAndFeel.h"
#include "nsAppShellSingleton.h"
#include "nsScreenManagerGonk.h"
#include "nsHTMLFormatConverter.h"
#include "nsXULAppAPI.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGonk)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_DEFINE_NAMED_CID(NS_APPSHELL_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);
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
{ &kNS_CHILD_CID, false, NULL, nsWindowConstructor },
{ &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
{ &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerGonkConstructor },
{ &kNS_HTMLFORMATCONVERTER_CID, false, NULL, nsHTMLFormatConverterConstructor },
{ NULL }
};
static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/widgets/window/gonk;1", &kNS_WINDOW_CID },
{ "@mozilla.org/widgets/child_window/gonk;1", &kNS_CHILD_CID },
{ "@mozilla.org/widget/appshell/gonk;1", &kNS_APPSHELL_CID },
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
{ "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
{ NULL }
};
static void
nsWidgetGonkModuleDtor()
{
nsLookAndFeel::Shutdown();
nsAppShellShutdown();
}
static const mozilla::Module kWidgetModule = {
mozilla::Module::kVersion,
kWidgetCIDs,
kWidgetContracts,
NULL,
NULL,
nsAppShellInit,
nsWidgetGonkModuleDtor
};
NSMODULE_DEFN(nsWidgetGonkModule) = &kWidgetModule;

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

@ -0,0 +1,359 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Gonk.
*
* The Initial Developer of the Original Code is
* the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAutoPtr.h"
#include "nsAppShell.h"
#include "nsTArray.h"
#include "nsWindow.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "ui/FramebufferNativeWindow.h"
#include "LayerManagerOGL.h"
#include "GLContextProvider.h"
#include "android/log.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
#define IS_TOPLEVEL() (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog)
using namespace mozilla::gl;
using namespace mozilla::layers;
nsIntRect gScreenBounds;
static nsRefPtr<GLContext> sGLContext;
static nsTArray<nsWindow *> sTopWindows;
static nsWindow *gWindowToRedraw = nsnull;
static nsWindow *gFocusedWindow = nsnull;
static android::FramebufferNativeWindow *gNativeWindow = nsnull;
nsWindow::nsWindow()
{
if (!sGLContext) {
gNativeWindow = new android::FramebufferNativeWindow();
sGLContext = GLContextProvider::CreateForWindow(this);
// CreateForWindow sets up gScreenBounds
}
}
nsWindow::~nsWindow()
{
}
void
nsWindow::DoDraw(void)
{
if (!gWindowToRedraw)
return;
nsPaintEvent event(true, NS_PAINT, gWindowToRedraw);
event.region = gScreenBounds;
static_cast<LayerManagerOGL*>(gWindowToRedraw->GetLayerManager(nsnull))->
SetClippingRegion(nsIntRegion(gScreenBounds));
gWindowToRedraw->mEventCallback(&event);
}
nsEventStatus
nsWindow::DispatchInputEvent(nsGUIEvent &aEvent)
{
if (!gFocusedWindow)
return nsEventStatus_eIgnore;
aEvent.widget = gFocusedWindow;
return gFocusedWindow->mEventCallback(&aEvent);
}
NS_IMETHODIMP
nsWindow::Create(nsIWidget *aParent,
void *aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsDeviceContext *aContext,
nsWidgetInitData *aInitData)
{
BaseCreate(aParent, IS_TOPLEVEL() ? gScreenBounds : aRect,
aHandleEventFunction, aContext, aInitData);
mBounds = aRect;
nsWindow *parent = (nsWindow *)aNativeParent;
mParent = parent;
if (!aNativeParent) {
mBounds = gScreenBounds;
}
if (!IS_TOPLEVEL())
return NS_OK;
sTopWindows.AppendElement(this);
Resize(0, 0, gScreenBounds.width, gScreenBounds.height, false);
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Destroy(void)
{
sTopWindows.RemoveElement(this);
if (this == gWindowToRedraw)
gWindowToRedraw = nsnull;
if (this == gFocusedWindow)
gFocusedWindow = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Show(bool aState)
{
if (!IS_TOPLEVEL())
return NS_OK;
if (aState)
BringToTop();
else
mVisible = false;
return NS_OK;
}
NS_IMETHODIMP
nsWindow::IsVisible(bool & aState)
{
aState = mVisible;
return NS_OK;
}
NS_IMETHODIMP
nsWindow::ConstrainPosition(bool aAllowSlop,
PRInt32 *aX,
PRInt32 *aY)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Move(PRInt32 aX,
PRInt32 aY)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Resize(PRInt32 aWidth,
PRInt32 aHeight,
bool aRepaint)
{
return Resize(0, 0, aWidth, aHeight, aRepaint);
}
NS_IMETHODIMP
nsWindow::Resize(PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight,
bool aRepaint)
{
nsSizeEvent event(true, NS_SIZE, this);
event.time = PR_Now() / 1000;
nsIntRect rect(aX, aY, aWidth, aHeight);
event.windowSize = &rect;
event.mWinWidth = gScreenBounds.width;
event.mWinHeight = gScreenBounds.height;
(*mEventCallback)(&event);
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Enable(bool aState)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::IsEnabled(bool *aState)
{
*aState = true;
return NS_OK;
}
NS_IMETHODIMP
nsWindow::SetFocus(bool aRaise)
{
if (aRaise)
BringToTop();
gFocusedWindow = this;
return NS_OK;
}
NS_IMETHODIMP
nsWindow::ConfigureChildren(const nsTArray<nsIWidget::Configuration>&)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Invalidate(const nsIntRect &aRect,
bool aIsSynchronous)
{
gWindowToRedraw = this;
gDrawRequest = true;
mozilla::NotifyEvent();
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Update()
{
Invalidate(gScreenBounds, false);
return NS_OK;
}
nsIntPoint
nsWindow::WidgetToScreenOffset()
{
nsIntPoint p(0, 0);
nsWindow *w = this;
while (w && w->mParent) {
p.x += w->mBounds.x;
p.y += w->mBounds.y;
w = w->mParent;
}
return p;
}
void*
nsWindow::GetNativeData(PRUint32 aDataType)
{
switch (aDataType) {
case NS_NATIVE_WINDOW:
return gNativeWindow;
case NS_NATIVE_WIDGET:
return this;
}
return nsnull;
}
NS_IMETHODIMP
nsWindow::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsWindow::ReparentNativeWidget(nsIWidget* aNewParent)
{
return NS_OK;
}
float
nsWindow::GetDPI()
{
return gNativeWindow->xdpi;
}
LayerManager *
nsWindow::GetLayerManager(PLayersChild* aShadowManager,
LayersBackend aBackendHint,
LayerManagerPersistence aPersistence,
bool* aAllowRetaining)
{
if (aAllowRetaining)
*aAllowRetaining = true;
if (mLayerManager)
return mLayerManager;
nsWindow *topWindow = sTopWindows[0];
if (!topWindow) {
LOG(" -- no topwindow\n");
return nsnull;
}
if (!sGLContext) {
LOG(" -- no GLContext\n");
return nsnull;
}
nsRefPtr<LayerManagerOGL> layerManager =
new LayerManagerOGL(this);
if (layerManager->Initialize(sGLContext))
mLayerManager = layerManager;
else
LOG("Could not create LayerManager");
return mLayerManager;
}
gfxASurface *
nsWindow::GetThebesSurface()
{
/* This is really a dummy surface; this is only used when doing reflow, because
* we need a RenderingContext to measure text against.
*/
// XXX this really wants to return already_AddRefed, but this only really gets used
// on direct assignment to a gfxASurface
return new gfxImageSurface(gfxIntSize(5,5), gfxImageSurface::ImageFormatRGB24);
}
void
nsWindow::BringToTop()
{
if (!sTopWindows.IsEmpty()) {
nsGUIEvent event(true, NS_DEACTIVATE, sTopWindows[0]);
(*mEventCallback)(&event);
}
sTopWindows.RemoveElement(this);
sTopWindows.InsertElementAt(0, this);
nsGUIEvent event(true, NS_ACTIVATE, this);
(*mEventCallback)(&event);
}

128
widget/src/gonk/nsWindow.h Normal file
Просмотреть файл

@ -0,0 +1,128 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Gonk.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Wu <mwu@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsWindow_h
#define nsWindow_h
#include "nsBaseWidget.h"
extern nsIntRect gScreenBounds;
namespace mozilla {
namespace gl {
class GLContext;
}
namespace layers {
class LayersManager;
}
}
namespace android {
class FramebufferNativeWindow;
}
class nsWindow : public nsBaseWidget
{
public:
nsWindow();
virtual ~nsWindow();
static void DoDraw(void);
static nsEventStatus DispatchInputEvent(nsGUIEvent &aEvent);
NS_IMETHOD Create(nsIWidget *aParent,
void *aNativeParent,
const nsIntRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsDeviceContext *aContext,
nsWidgetInitData *aInitData);
NS_IMETHOD Destroy(void);
NS_IMETHOD Show(bool aState);
NS_IMETHOD IsVisible(bool & aState);
NS_IMETHOD ConstrainPosition(bool aAllowSlop,
PRInt32 *aX,
PRInt32 *aY);
NS_IMETHOD Move(PRInt32 aX,
PRInt32 aY);
NS_IMETHOD Resize(PRInt32 aWidth,
PRInt32 aHeight,
bool aRepaint);
NS_IMETHOD Resize(PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight,
bool aRepaint);
NS_IMETHOD Enable(bool aState);
NS_IMETHOD IsEnabled(bool *aState);
NS_IMETHOD SetFocus(bool aRaise = false);
NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&);
NS_IMETHOD Invalidate(const nsIntRect &aRect,
bool aIsSynchronous);
NS_IMETHOD Update();
virtual void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD SetTitle(const nsAString& aTitle)
{
return NS_OK;
}
virtual nsIntPoint WidgetToScreenOffset();
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus &aStatus);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
nsIMenuRollup *aMenuRollup,
bool aDoCapture,
bool aConsumeRollupEvent)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHOD ReparentNativeWidget(nsIWidget* aNewParent);
virtual float GetDPI();
virtual mozilla::layers::LayerManager*
GetLayerManager(PLayersChild* aShadowManager = nsnull,
LayersBackend aBackendHint = LayerManager::LAYERS_NONE,
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT,
bool* aAllowRetaining = nsnull);
gfxASurface* GetThebesSurface();
protected:
nsWindow* mParent;
bool mVisible;
void BringToTop();
};
#endif /* nsWindow_h */

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

@ -82,7 +82,7 @@ ifneq (,$(filter os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += nsBaseClipboard.cpp
endif
ifneq (,$(filter qt gtk2 os2 cocoa windows android,$(MOZ_WIDGET_TOOLKIT)))
ifneq (,$(filter qt gtk2 os2 cocoa windows android gonk,$(MOZ_WIDGET_TOOLKIT)))
CPPSRCS += nsBaseFilePicker.cpp
endif

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

@ -49,7 +49,7 @@
#include <gtk/gtk.h>
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -174,7 +174,7 @@ nsSystemInfo::Init()
}
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
if (mozilla::AndroidBridge::Bridge()) {
nsAutoString str;
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", str))

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

@ -52,7 +52,7 @@
#include <gtk/gtk.h>
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#endif
@ -502,7 +502,7 @@ ParseManifestCommon(NSLocationType aType, nsILocalFile* aFile,
nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
gtk_major_version,
gtk_minor_version);
#elif defined(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
if (mozilla::AndroidBridge::Bridge()) {
mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", osVersion);
}

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

@ -113,7 +113,7 @@ static nsresult MacErrorMapper(OSErr inErr);
#include <libosso.h>
#endif
#ifdef ANDROID
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#include "nsIMIMEService.h"
#include <linux/magic.h>
@ -1885,7 +1885,7 @@ nsLocalFile::Launch()
}
return NS_ERROR_FAILURE;
#elif defined(ANDROID)
#elif defined(MOZ_WIDGET_ANDROID)
// Try to get a mimetype, if this fails just use the file uri alone
nsresult rv;
nsCAutoString type;