Merge remote-tracking branch 'origin/master' into custom

This commit is contained in:
Roy Tam 2020-02-21 07:18:31 +08:00
commit 43b8e8fb16
212 changed files with 94 additions and 52404 deletions

View file

@ -125,10 +125,8 @@
#endif #endif
@RESPATH@/platform.ini @RESPATH@/platform.ini
#ifndef MOZ_SYSTEM_SQLITE #ifndef MOZ_SYSTEM_SQLITE
#ifndef MOZ_FOLD_LIBS
@BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@
#endif #endif
#endif
@BINPATH@/@DLL_PREFIX@lgpllibs@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@lgpllibs@DLL_SUFFIX@
#ifdef MOZ_FFVPX #ifdef MOZ_FFVPX
@BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@

View file

@ -166,7 +166,7 @@ pref("app.update.silent", false);
pref("app.update.staging.enabled", true); pref("app.update.staging.enabled", true);
// Update service URL: // Update service URL:
pref("app.update.url", "https://aus.palemoon.org/?application=%PRODUCT%&version=%VERSION%&arch=%BUILD_TARGET%&toolkit=%WIDGET_TOOLKIT%&buildid=%BUILD_ID%&channel=%CHANNEL%"); pref("app.update.url", "https://aus.palemoon.org/?application=%PRODUCT%&version=%VERSION%&arch=%BUILD_TARGET%&flavor=%BUILD_SPECIAL%&toolkit=%WIDGET_TOOLKIT%&buildid=%BUILD_ID%&channel=%CHANNEL%");
// app.update.url.manual is in branding section // app.update.url.manual is in branding section
// app.update.url.details is in branding section // app.update.url.details is in branding section

View file

@ -87,11 +87,6 @@ MOZ_CHROME_FILE_FORMAT=omni
# Set the default top-level extensions # Set the default top-level extensions
MOZ_EXTENSIONS_DEFAULT=" gio" MOZ_EXTENSIONS_DEFAULT=" gio"
# Fold Libs
if test "$OS_TARGET" = "WINNT" -o "$OS_TARGET" = "Darwin"; then
MOZ_FOLD_LIBS=1
fi
# Include bundled fonts # Include bundled fonts
if test "$OS_ARCH" = "WINNT" -o \ if test "$OS_ARCH" = "WINNT" -o \
"$OS_ARCH" = "Linux"; then "$OS_ARCH" = "Linux"; then

View file

@ -126,10 +126,8 @@
#endif #endif
@RESPATH@/platform.ini @RESPATH@/platform.ini
#ifndef MOZ_SYSTEM_SQLITE #ifndef MOZ_SYSTEM_SQLITE
#ifndef MOZ_FOLD_LIBS
@BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@
#endif #endif
#endif
@BINPATH@/@DLL_PREFIX@lgpllibs@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@lgpllibs@DLL_SUFFIX@
#ifdef MOZ_FFVPX #ifdef MOZ_FFVPX
@BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@ @BINPATH@/@DLL_PREFIX@mozavutil@DLL_SUFFIX@

View file

@ -6,10 +6,8 @@
external_dirs = [] external_dirs = []
DIRS += [ DIRS += ['lgpllibs']
'lgpllibs',
'sqlite',
]
if not CONFIG['MOZ_SYSTEM_JPEG']: if not CONFIG['MOZ_SYSTEM_JPEG']:
external_dirs += ['media/libjpeg'] external_dirs += ['media/libjpeg']

View file

@ -119,12 +119,8 @@ DEFAULT_GMAKE_FLAGS += NSS_ENABLE_TLS_1_3=1
ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_1) ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_1)
DEFAULT_GMAKE_FLAGS += OS_DLLFLAGS='-static-libgcc' NSPR31_LIB_PREFIX=lib DEFAULT_GMAKE_FLAGS += OS_DLLFLAGS='-static-libgcc' NSPR31_LIB_PREFIX=lib
endif endif
ifdef MOZ_FOLD_LIBS
DEFAULT_GMAKE_FLAGS += SQLITE_LIB_NAME=nss3
else
DEFAULT_GMAKE_FLAGS += SQLITE_LIB_NAME=mozsqlite3 DEFAULT_GMAKE_FLAGS += SQLITE_LIB_NAME=mozsqlite3
DEFAULT_GMAKE_FLAGS += SQLITE_LIB_DIR=$(ABS_DIST)/../config/external/sqlite DEFAULT_GMAKE_FLAGS += SQLITE_LIB_DIR=$(ABS_DIST)/../db/sqlite3/src
endif # MOZ_FOLD_LIBS
DEFAULT_GMAKE_FLAGS += SQLITE_INCLUDE_DIR=$(ABS_DIST)/include DEFAULT_GMAKE_FLAGS += SQLITE_INCLUDE_DIR=$(ABS_DIST)/include
ifdef NSS_DISABLE_DBM ifdef NSS_DISABLE_DBM
DEFAULT_GMAKE_FLAGS += NSS_DISABLE_DBM=1 DEFAULT_GMAKE_FLAGS += NSS_DISABLE_DBM=1

View file

@ -29,9 +29,10 @@ else:
'/security/nss/lib/smime/smime3', '/security/nss/lib/smime/smime3',
'/security/nss/lib/ssl/ssl3', '/security/nss/lib/ssl/ssl3',
'/security/nss/lib/util/nssutil3', '/security/nss/lib/util/nssutil3',
'sqlite',
] ]
USE_LIBS += ['sqlite']
# XXX: We should fix these warnings. # XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True ALLOW_COMPILER_WARNINGS = True

View file

@ -13,7 +13,6 @@
PR_* PR_*
PL_* PL_*
#endif #endif
#include ../../../db/sqlite3/src/sqlite.symbols
ATOB_AsciiToData ATOB_AsciiToData
ATOB_AsciiToData_Util ATOB_AsciiToData_Util
ATOB_ConvertAsciiToItem ATOB_ConvertAsciiToItem

View file

@ -1,18 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['../../../db/sqlite3/src']
if CONFIG['MOZ_FOLD_LIBS']:
Library('sqlite')
# When folding libraries, sqlite is actually in the nss library.
USE_LIBS += [
'nss',
]
else:
SharedLibrary('sqlite')
SHARED_LIBRARY_NAME = 'mozsqlite3'
SYMBOLS_FILE = '/db/sqlite3/src/sqlite.symbols'

View file

@ -3,25 +3,18 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
NO_VISIBILITY_FLAGS = True
EXPORTS += [ NO_VISIBILITY_FLAGS = True
'sqlite3.h',
]
# We allow warnings for third-party code that can be updated from upstream. # We allow warnings for third-party code that can be updated from upstream.
ALLOW_COMPILER_WARNINGS = True ALLOW_COMPILER_WARNINGS = True
if CONFIG['MOZ_FOLD_LIBS']: GeckoSharedLibrary('sqlite', linkage=None, mozglue='library')
# When folding libraries, sqlite is actually in the nss library. SHARED_LIBRARY_NAME = 'mozsqlite3'
FINAL_LIBRARY = 'nss' SYMBOLS_FILE = 'sqlite.symbols'
else:
# The final library is in config/external/sqlite
FINAL_LIBRARY = 'sqlite'
SOURCES += [ EXPORTS += ['sqlite3.h']
'sqlite3.c', SOURCES += ['sqlite3.c']
]
# -DSQLITE_SECURE_DELETE=1 will cause SQLITE to 0-fill delete data so we # -DSQLITE_SECURE_DELETE=1 will cause SQLITE to 0-fill delete data so we
# don't have to vacuum to make sure the data is not visible in the file. # don't have to vacuum to make sure the data is not visible in the file.
@ -34,8 +27,11 @@ SOURCES += [
# hidden preference. If that preference is missing or invalid then this value # hidden preference. If that preference is missing or invalid then this value
# will be used. # will be used.
# Note: Be sure to update the configure.in checks when these change! # Note: Be sure to update the configure.in checks when these change!
for var in ('SQLITE_SECURE_DELETE', 'SQLITE_THREADSAFE', 'SQLITE_CORE', for var in ('SQLITE_SECURE_DELETE',
'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_UNLOCK_NOTIFY', 'SQLITE_THREADSAFE',
'SQLITE_CORE',
'SQLITE_ENABLE_FTS3',
'SQLITE_ENABLE_UNLOCK_NOTIFY',
'SQLITE_ENABLE_DBSTAT_VTAB'): 'SQLITE_ENABLE_DBSTAT_VTAB'):
DEFINES[var] = 1 DEFINES[var] = 1

View file

@ -96,8 +96,10 @@ public:
IMPL_EVENT_HANDLER(resourcetimingbufferfull) IMPL_EVENT_HANDLER(resourcetimingbufferfull)
#ifdef MOZ_DEVTOOLS_SERVER
virtual void GetMozMemory(JSContext *aCx, virtual void GetMozMemory(JSContext *aCx,
JS::MutableHandle<JSObject*> aObj) = 0; JS::MutableHandle<JSObject*> aObj) = 0;
#endif
virtual nsDOMNavigationTiming* GetDOMTiming() const = 0; virtual nsDOMNavigationTiming* GetDOMTiming() const = 0;

View file

@ -11,6 +11,7 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread) NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread, NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
@ -18,8 +19,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming, NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming,
mNavigation, mNavigation,
mDocEntry) mDocEntry)
#ifdef MOZ_DEVTOOLS_SERVER
tmp->mMozMemory = nullptr; tmp->mMozMemory = nullptr;
mozilla::DropJSObjects(this); mozilla::DropJSObjects(this);
#endif
NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PerformanceMainThread,
@ -31,7 +34,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PerformanceMainThread, NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PerformanceMainThread,
Performance) Performance)
#ifdef MOZ_DEVTOOLS_SERVER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mMozMemory) NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mMozMemory)
#endif
NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_ADDREF_INHERITED(PerformanceMainThread, Performance) NS_IMPL_ADDREF_INHERITED(PerformanceMainThread, Performance)
@ -55,9 +60,12 @@ PerformanceMainThread::PerformanceMainThread(nsPIDOMWindowInner* aWindow,
PerformanceMainThread::~PerformanceMainThread() PerformanceMainThread::~PerformanceMainThread()
{ {
#ifdef MOZ_DEVTOOLS_SERVER
mozilla::DropJSObjects(this); mozilla::DropJSObjects(this);
#endif
} }
#ifdef MOZ_DEVTOOLS_SERVER
void void
PerformanceMainThread::GetMozMemory(JSContext *aCx, PerformanceMainThread::GetMozMemory(JSContext *aCx,
JS::MutableHandle<JSObject*> aObj) JS::MutableHandle<JSObject*> aObj)
@ -71,6 +79,7 @@ PerformanceMainThread::GetMozMemory(JSContext *aCx,
aObj.set(mMozMemory); aObj.set(mMozMemory);
} }
#endif
PerformanceTiming* PerformanceTiming*
PerformanceMainThread::Timing() PerformanceMainThread::Timing()

View file

@ -34,8 +34,10 @@ public:
DOMHighResTimeStamp CreationTime() const override; DOMHighResTimeStamp CreationTime() const override;
#ifdef MOZ_DEVTOOLS_SERVER
virtual void GetMozMemory(JSContext *aCx, virtual void GetMozMemory(JSContext *aCx,
JS::MutableHandle<JSObject*> aObj) override; JS::MutableHandle<JSObject*> aObj) override;
#endif
virtual nsDOMNavigationTiming* GetDOMTiming() const override virtual nsDOMNavigationTiming* GetDOMTiming() const override
{ {
@ -79,7 +81,9 @@ protected:
nsCOMPtr<nsITimedChannel> mChannel; nsCOMPtr<nsITimedChannel> mChannel;
RefPtr<PerformanceTiming> mTiming; RefPtr<PerformanceTiming> mTiming;
RefPtr<PerformanceNavigation> mNavigation; RefPtr<PerformanceNavigation> mNavigation;
#ifdef MOZ_DEVTOOLS_SERVER
JS::Heap<JSObject*> mMozMemory; JS::Heap<JSObject*> mMozMemory;
#endif
}; };
} // namespace dom } // namespace dom

View file

@ -43,11 +43,13 @@ public:
DOMHighResTimeStamp CreationTime() const override; DOMHighResTimeStamp CreationTime() const override;
#ifdef MOZ_DEVTOOLS_SERVER
virtual void GetMozMemory(JSContext *aCx, virtual void GetMozMemory(JSContext *aCx,
JS::MutableHandle<JSObject*> aObj) override JS::MutableHandle<JSObject*> aObj) override
{ {
MOZ_CRASH("This should not be called on workers."); MOZ_CRASH("This should not be called on workers.");
} }
#endif
virtual nsDOMNavigationTiming* GetDOMTiming() const override virtual nsDOMNavigationTiming* GetDOMTiming() const override
{ {

View file

@ -21,43 +21,10 @@ static int gNotOptimized;
#define CALLING_CONVENTION_HACK #define CALLING_CONVENTION_HACK
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
#include "AndroidBridge.h"
#include "android_npapi.h"
#include <android/log.h>
#undef ALOG
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoJavaEnv", ## args)
#endif
using namespace mozilla::layers; using namespace mozilla::layers;
namespace mozilla { namespace mozilla {
#ifdef MOZ_WIDGET_ANDROID #if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error)
{
JNIEnv* env = jni::GetEnvForThread();
mozilla::AutoLocalJNIFrame jniFrame(env);
if (mNP_Initialize) {
*error = mNP_Initialize(bFuncs, pFuncs, env);
} else {
NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
if (!pfNP_Initialize)
return NS_ERROR_FAILURE;
*error = pfNP_Initialize(bFuncs, pFuncs, env);
}
// Save pointers to functions that get called through PluginLibrary itself.
mNPP_New = pFuncs->newp;
mNPP_ClearSiteData = pFuncs->clearsitedata;
mNPP_GetSitesWithData = pFuncs->getsiteswithdata;
return NS_OK;
}
#elif defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult nsresult
PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
NPPluginFuncs* pFuncs, NPError* error) NPPluginFuncs* pFuncs, NPError* error)

View file

@ -1,390 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "AndroidBridge.h"
#include <android/log.h>
#include <stdlib.h>
#include <time.h>
#include "assert.h"
#include "ANPBase.h"
#include "nsIThread.h"
#include "nsThreadUtils.h"
#include "mozilla/Mutex.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPluginsAudio" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_audio_##name
/* android.media.AudioTrack */
struct AudioTrack {
jclass at_class;
jmethodID constructor;
jmethodID flush;
jmethodID pause;
jmethodID play;
jmethodID setvol;
jmethodID stop;
jmethodID write;
jmethodID getpos;
jmethodID getstate;
jmethodID release;
};
enum AudioTrackMode {
MODE_STATIC = 0,
MODE_STREAM = 1
};
/* android.media.AudioManager */
enum AudioManagerStream {
STREAM_VOICE_CALL = 0,
STREAM_SYSTEM = 1,
STREAM_RING = 2,
STREAM_MUSIC = 3,
STREAM_ALARM = 4,
STREAM_NOTIFICATION = 5,
STREAM_DTMF = 8
};
/* android.media.AudioFormat */
enum AudioFormatChannel {
CHANNEL_OUT_MONO = 4,
CHANNEL_OUT_STEREO = 12
};
enum AudioFormatEncoding {
ENCODING_PCM_16BIT = 2,
ENCODING_PCM_8BIT = 3
};
enum AudioFormatState {
STATE_UNINITIALIZED = 0,
STATE_INITIALIZED = 1,
STATE_NO_STATIC_DATA = 2
};
static struct AudioTrack at;
static jclass
init_jni_bindings(JNIEnv *jenv) {
jclass jc =
(jclass)jenv->NewGlobalRef(jenv->FindClass("android/media/AudioTrack"));
at.constructor = jenv->GetMethodID(jc, "<init>", "(IIIIII)V");
at.flush = jenv->GetMethodID(jc, "flush", "()V");
at.pause = jenv->GetMethodID(jc, "pause", "()V");
at.play = jenv->GetMethodID(jc, "play", "()V");
at.setvol = jenv->GetMethodID(jc, "setStereoVolume", "(FF)I");
at.stop = jenv->GetMethodID(jc, "stop", "()V");
at.write = jenv->GetMethodID(jc, "write", "([BII)I");
at.getpos = jenv->GetMethodID(jc, "getPlaybackHeadPosition", "()I");
at.getstate = jenv->GetMethodID(jc, "getState", "()I");
at.release = jenv->GetMethodID(jc, "release", "()V");
return jc;
}
struct ANPAudioTrack {
jobject output_unit;
jclass at_class;
unsigned int rate;
unsigned int channels;
unsigned int bufferSize;
unsigned int isStopped;
unsigned int keepGoing;
mozilla::Mutex lock;
void* user;
ANPAudioCallbackProc proc;
ANPSampleFormat format;
ANPAudioTrack() : lock("ANPAudioTrack") { }
};
class AudioRunnable : public mozilla::Runnable
{
public:
NS_DECL_NSIRUNNABLE
AudioRunnable(ANPAudioTrack* aAudioTrack) {
mTrack = aAudioTrack;
}
ANPAudioTrack* mTrack;
};
NS_IMETHODIMP
AudioRunnable::Run()
{
PR_SetCurrentThreadName("Android Audio");
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
mozilla::AutoLocalJNIFrame autoFrame(jenv, 2);
jbyteArray bytearray = jenv->NewByteArray(mTrack->bufferSize);
if (!bytearray) {
LOG("AudioRunnable:: Run. Could not create bytearray");
return NS_ERROR_FAILURE;
}
jbyte *byte = jenv->GetByteArrayElements(bytearray, nullptr);
if (!byte) {
LOG("AudioRunnable:: Run. Could not create bytearray");
return NS_ERROR_FAILURE;
}
ANPAudioBuffer buffer;
buffer.channelCount = mTrack->channels;
buffer.format = mTrack->format;
buffer.bufferData = (void*) byte;
while (true)
{
// reset the buffer size
buffer.size = mTrack->bufferSize;
{
mozilla::MutexAutoLock lock(mTrack->lock);
if (!mTrack->keepGoing)
break;
// Get data from the plugin
mTrack->proc(kMoreData_ANPAudioEvent, mTrack->user, &buffer);
}
if (buffer.size == 0) {
LOG("%p - kMoreData_ANPAudioEvent", mTrack);
continue;
}
size_t wroteSoFar = 0;
jint retval;
do {
retval = jenv->CallIntMethod(mTrack->output_unit,
at.write,
bytearray,
wroteSoFar,
buffer.size - wroteSoFar);
if (retval < 0) {
LOG("%p - Write failed %d", mTrack, retval);
break;
}
wroteSoFar += retval;
} while(wroteSoFar < buffer.size);
}
jenv->CallVoidMethod(mTrack->output_unit, at.release);
jenv->DeleteGlobalRef(mTrack->output_unit);
jenv->DeleteGlobalRef(mTrack->at_class);
delete mTrack;
jenv->ReleaseByteArrayElements(bytearray, byte, 0);
return NS_OK;
}
ANPAudioTrack*
anp_audio_newTrack(uint32_t sampleRate, // sampling rate in Hz
ANPSampleFormat format,
int channelCount, // MONO=1, STEREO=2
ANPAudioCallbackProc proc,
void* user)
{
ANPAudioTrack *s = new ANPAudioTrack();
if (s == nullptr) {
return nullptr;
}
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
s->at_class = init_jni_bindings(jenv);
s->rate = sampleRate;
s->channels = channelCount;
s->bufferSize = s->rate * s->channels;
s->isStopped = true;
s->keepGoing = false;
s->user = user;
s->proc = proc;
s->format = format;
int jformat;
switch (format) {
case kPCM16Bit_ANPSampleFormat:
jformat = ENCODING_PCM_16BIT;
break;
case kPCM8Bit_ANPSampleFormat:
jformat = ENCODING_PCM_8BIT;
break;
default:
LOG("Unknown audio format. defaulting to 16bit.");
jformat = ENCODING_PCM_16BIT;
break;
}
int jChannels;
switch (channelCount) {
case 1:
jChannels = CHANNEL_OUT_MONO;
break;
case 2:
jChannels = CHANNEL_OUT_STEREO;
break;
default:
LOG("Unknown channel count. defaulting to mono.");
jChannels = CHANNEL_OUT_MONO;
break;
}
mozilla::AutoLocalJNIFrame autoFrame(jenv);
jobject obj = jenv->NewObject(s->at_class,
at.constructor,
STREAM_MUSIC,
s->rate,
jChannels,
jformat,
s->bufferSize,
MODE_STREAM);
if (autoFrame.CheckForException() || obj == nullptr) {
jenv->DeleteGlobalRef(s->at_class);
delete s;
return nullptr;
}
jint state = jenv->CallIntMethod(obj, at.getstate);
if (autoFrame.CheckForException() || state == STATE_UNINITIALIZED) {
jenv->DeleteGlobalRef(s->at_class);
delete s;
return nullptr;
}
s->output_unit = jenv->NewGlobalRef(obj);
return s;
}
void
anp_audio_deleteTrack(ANPAudioTrack* s)
{
if (s == nullptr) {
return;
}
mozilla::MutexAutoLock lock(s->lock);
s->keepGoing = false;
// deallocation happens in the AudioThread. There is a
// potential leak if anp_audio_start is never called, but
// we do not see that from flash.
}
void
anp_audio_start(ANPAudioTrack* s)
{
if (s == nullptr || s->output_unit == nullptr) {
return;
}
if (s->keepGoing) {
// we are already playing. Ignore.
return;
}
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
jenv->CallVoidMethod(s->output_unit, at.play);
if (autoFrame.CheckForException()) {
jenv->DeleteGlobalRef(s->at_class);
delete s;
return;
}
s->isStopped = false;
s->keepGoing = true;
// AudioRunnable now owns the ANPAudioTrack
RefPtr<AudioRunnable> runnable = new AudioRunnable(s);
nsCOMPtr<nsIThread> thread;
NS_NewThread(getter_AddRefs(thread), runnable);
}
void
anp_audio_pause(ANPAudioTrack* s)
{
if (s == nullptr || s->output_unit == nullptr) {
return;
}
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
jenv->CallVoidMethod(s->output_unit, at.pause);
}
void
anp_audio_stop(ANPAudioTrack* s)
{
if (s == nullptr || s->output_unit == nullptr) {
return;
}
s->isStopped = true;
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
mozilla::AutoLocalJNIFrame autoFrame(jenv, 0);
jenv->CallVoidMethod(s->output_unit, at.stop);
}
bool
anp_audio_isStopped(ANPAudioTrack* s)
{
return s->isStopped;
}
uint32_t
anp_audio_trackLatency(ANPAudioTrack* s) {
// Hardcode an estimate of the system's audio latency. Flash hardcodes
// similar latency estimates for pre-Honeycomb devices that do not support
// ANPAudioTrackInterfaceV1's trackLatency(). The Android stock browser
// calls android::AudioTrack::latency(), an internal Android API that is
// not available in the public NDK:
// https://github.com/android/platform_external_webkit/commit/49bf866973cb3b2a6c74c0eab864e9562e4cbab1
return 100; // milliseconds
}
void InitAudioTrackInterfaceV0(ANPAudioTrackInterfaceV0 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, newTrack);
ASSIGN(i, deleteTrack);
ASSIGN(i, start);
ASSIGN(i, pause);
ASSIGN(i, stop);
ASSIGN(i, isStopped);
}
void InitAudioTrackInterfaceV1(ANPAudioTrackInterfaceV1 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, newTrack);
ASSIGN(i, deleteTrack);
ASSIGN(i, start);
ASSIGN(i, pause);
ASSIGN(i, stop);
ASSIGN(i, isStopped);
ASSIGN(i, trackLatency);
}

View file

@ -1,36 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <stdlib.h>
#include "android_npapi.h"
#include "nsISupportsImpl.h"
#define NOT_IMPLEMENTED_FATAL() do { \
__android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins", \
"%s not implemented %s, %d", \
__PRETTY_FUNCTION__, __FILE__, __LINE__); \
abort(); \
} while(0)
#define NOT_IMPLEMENTED() \
__android_log_print(ANDROID_LOG_ERROR, "GeckoPlugins", \
"!!!!!!!!!!!!!! %s not implemented %s, %d", \
__PRETTY_FUNCTION__, __FILE__, __LINE__); \
void InitAudioTrackInterfaceV0(ANPAudioTrackInterfaceV0 *i);
void InitAudioTrackInterfaceV1(ANPAudioTrackInterfaceV1* i);
void InitCanvasInterface(ANPCanvasInterfaceV0 *i);
void InitEventInterface(ANPEventInterfaceV0 *i);
void InitLogInterface(ANPLogInterfaceV0 *i);
void InitPaintInterface(ANPPaintInterfaceV0 *i);
void InitSurfaceInterface(ANPSurfaceInterfaceV0 *i);
void InitSystemInterfaceV1(ANPSystemInterfaceV1 *i);
void InitSystemInterfaceV2(ANPSystemInterfaceV2 *i);
void InitTypeFaceInterface(ANPTypefaceInterfaceV0 *i);
void InitWindowInterface(ANPWindowInterfaceV0 *i);
void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i);
void InitVideoInterfaceV1(ANPVideoInterfaceV1 *i);
void InitOpenGLInterface(ANPOpenGLInterfaceV0 *i);
void InitNativeWindowInterface(ANPNativeWindowInterfaceV0 *i);

View file

@ -1,31 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "assert.h"
#include "ANPBase.h"
#include <android/log.h>
#include "nsThreadUtils.h"
#include "nsNPAPIPluginInstance.h"
#include "nsNPAPIPlugin.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_event_##name
void
anp_event_postEvent(NPP instance, const ANPEvent* event)
{
LOG("%s", __PRETTY_FUNCTION__);
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
pinst->PostEvent((void*) event);
LOG("returning from %s", __PRETTY_FUNCTION__);
}
void InitEventInterface(ANPEventInterfaceV0 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, postEvent);
}

View file

@ -1,152 +0,0 @@
/*
* Copyright 2008, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANPKeyCodes_DEFINED
#define ANPKeyCodes_DEFINED
/* List the key codes that are set to a plugin in the ANPKeyEvent.
These exactly match the values in android/view/KeyEvent.java and the
corresponding .h file android/keycodes.h.
*/
enum ANPKeyCodes {
kUnknown_ANPKeyCode = 0,
kSoftLeft_ANPKeyCode = 1,
kSoftRight_ANPKeyCode = 2,
kHome_ANPKeyCode = 3,
kBack_ANPKeyCode = 4,
kCall_ANPKeyCode = 5,
kEndCall_ANPKeyCode = 6,
k0_ANPKeyCode = 7,
k1_ANPKeyCode = 8,
k2_ANPKeyCode = 9,
k3_ANPKeyCode = 10,
k4_ANPKeyCode = 11,
k5_ANPKeyCode = 12,
k6_ANPKeyCode = 13,
k7_ANPKeyCode = 14,
k8_ANPKeyCode = 15,
k9_ANPKeyCode = 16,
kStar_ANPKeyCode = 17,
kPound_ANPKeyCode = 18,
kDpadUp_ANPKeyCode = 19,
kDpadDown_ANPKeyCode = 20,
kDpadLeft_ANPKeyCode = 21,
kDpadRight_ANPKeyCode = 22,
kDpadCenter_ANPKeyCode = 23,
kVolumeUp_ANPKeyCode = 24,
kVolumeDown_ANPKeyCode = 25,
kPower_ANPKeyCode = 26,
kCamera_ANPKeyCode = 27,
kClear_ANPKeyCode = 28,
kA_ANPKeyCode = 29,
kB_ANPKeyCode = 30,
kC_ANPKeyCode = 31,
kD_ANPKeyCode = 32,
kE_ANPKeyCode = 33,
kF_ANPKeyCode = 34,
kG_ANPKeyCode = 35,
kH_ANPKeyCode = 36,
kI_ANPKeyCode = 37,
kJ_ANPKeyCode = 38,
kK_ANPKeyCode = 39,
kL_ANPKeyCode = 40,
kM_ANPKeyCode = 41,
kN_ANPKeyCode = 42,
kO_ANPKeyCode = 43,
kP_ANPKeyCode = 44,
kQ_ANPKeyCode = 45,
kR_ANPKeyCode = 46,
kS_ANPKeyCode = 47,
kT_ANPKeyCode = 48,
kU_ANPKeyCode = 49,
kV_ANPKeyCode = 50,
kW_ANPKeyCode = 51,
kX_ANPKeyCode = 52,
kY_ANPKeyCode = 53,
kZ_ANPKeyCode = 54,
kComma_ANPKeyCode = 55,
kPeriod_ANPKeyCode = 56,
kAltLeft_ANPKeyCode = 57,
kAltRight_ANPKeyCode = 58,
kShiftLeft_ANPKeyCode = 59,
kShiftRight_ANPKeyCode = 60,
kTab_ANPKeyCode = 61,
kSpace_ANPKeyCode = 62,
kSym_ANPKeyCode = 63,
kExplorer_ANPKeyCode = 64,
kEnvelope_ANPKeyCode = 65,
kNewline_ANPKeyCode = 66,
kDel_ANPKeyCode = 67,
kGrave_ANPKeyCode = 68,
kMinus_ANPKeyCode = 69,
kEquals_ANPKeyCode = 70,
kLeftBracket_ANPKeyCode = 71,
kRightBracket_ANPKeyCode = 72,
kBackslash_ANPKeyCode = 73,
kSemicolon_ANPKeyCode = 74,
kApostrophe_ANPKeyCode = 75,
kSlash_ANPKeyCode = 76,
kAt_ANPKeyCode = 77,
kNum_ANPKeyCode = 78,
kHeadSetHook_ANPKeyCode = 79,
kFocus_ANPKeyCode = 80,
kPlus_ANPKeyCode = 81,
kMenu_ANPKeyCode = 82,
kNotification_ANPKeyCode = 83,
kSearch_ANPKeyCode = 84,
kMediaPlayPause_ANPKeyCode = 85,
kMediaStop_ANPKeyCode = 86,
kMediaNext_ANPKeyCode = 87,
kMediaPrevious_ANPKeyCode = 88,
kMediaRewind_ANPKeyCode = 89,
kMediaFastForward_ANPKeyCode = 90,
kMute_ANPKeyCode = 91,
kPageUp_ANPKeyCode = 92,
kPageDown_ANPKeyCode = 93,
kPictsymbols_ANPKeyCode = 94,
kSwitchCharset_ANPKeyCode = 95,
kButtonA_ANPKeyCode = 96,
kButtonB_ANPKeyCode = 97,
kButtonC_ANPKeyCode = 98,
kButtonX_ANPKeyCode = 99,
kButtonY_ANPKeyCode = 100,
kButtonZ_ANPKeyCode = 101,
kButtonL1_ANPKeyCode = 102,
kButtonR1_ANPKeyCode = 103,
kButtonL2_ANPKeyCode = 104,
kButtonR2_ANPKeyCode = 105,
kButtonThumbL_ANPKeyCode = 106,
kButtonThumbR_ANPKeyCode = 107,
kButtonStart_ANPKeyCode = 108,
kButtonSelect_ANPKeyCode = 109,
kButtonMode_ANPKeyCode = 110,
// NOTE: If you add a new keycode here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
};
#endif

View file

@ -1,26 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "assert.h"
#include "ANPBase.h"
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_log_##name
void
anp_log_log(ANPLogType type, const char format[], ...) {
va_list argp;
va_start(argp,format);
__android_log_vprint(type == kError_ANPLogType ? ANDROID_LOG_ERROR : type == kWarning_ANPLogType ?
ANDROID_LOG_WARN : ANDROID_LOG_INFO, "GeckoPluginLog", format, argp);
va_end(argp);
}
void InitLogInterface(ANPLogInterfaceV0 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, log);
}

View file

@ -1,39 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// must include config.h first for webkit to fiddle with new/delete
#include <android/log.h>
#include "ANPBase.h"
#include "nsIPluginInstanceOwner.h"
#include "nsPluginInstanceOwner.h"
#include "nsNPAPIPluginInstance.h"
#include "gfxRect.h"
using namespace mozilla;
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_native_window_##name
static ANPNativeWindow anp_native_window_acquireNativeWindow(NPP instance) {
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
return pinst->AcquireContentWindow();
}
static void anp_native_window_invertPluginContent(NPP instance, bool isContentInverted) {
// NativeWindow is TopLeft if uninverted.
gl::OriginPos newOriginPos = gl::OriginPos::TopLeft;
if (isContentInverted)
newOriginPos = gl::OriginPos::BottomLeft;
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
pinst->SetOriginPos(newOriginPos);
pinst->RedrawPlugin();
}
void InitNativeWindowInterface(ANPNativeWindowInterfaceV0* i) {
ASSIGN(i, acquireNativeWindow);
ASSIGN(i, invertPluginContent);
}

View file

@ -1,266 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <dlfcn.h>
#include <android/log.h>
#include "ANPBase.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_surface_##name
#define CLEAR_EXCEPTION(env) if (env->ExceptionOccurred()) env->ExceptionClear();
#define ANDROID_REGION_SIZE 512
enum {
PIXEL_FORMAT_RGBA_8888 = 1,
PIXEL_FORMAT_RGB_565 = 4,
};
struct SurfaceInfo {
uint32_t w;
uint32_t h;
uint32_t s;
uint32_t usage;
uint32_t format;
unsigned char* bits;
uint32_t reserved[2];
};
typedef struct ARect {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
} ARect;
// used to cache JNI method and field IDs for Surface Objects
static struct ANPSurfaceInterfaceJavaGlue {
bool initialized;
jmethodID getSurfaceHolder;
jmethodID getSurface;
jfieldID surfacePointer;
} gSurfaceJavaGlue;
static struct ANPSurfaceFunctions {
bool initialized;
int (* lock)(void*, SurfaceInfo*, void*);
int (* unlockAndPost)(void*);
void* (* regionConstructor)(void*);
void (* setRegion)(void*, ARect const&);
} gSurfaceFunctions;
static inline void* getSurface(JNIEnv* env, jobject view) {
if (!env || !view) {
return nullptr;
}
if (!gSurfaceJavaGlue.initialized) {
jclass surfaceViewClass = env->FindClass("android/view/SurfaceView");
gSurfaceJavaGlue.getSurfaceHolder = env->GetMethodID(surfaceViewClass, "getHolder", "()Landroid/view/SurfaceHolder;");
jclass surfaceHolderClass = env->FindClass("android/view/SurfaceHolder");
gSurfaceJavaGlue.getSurface = env->GetMethodID(surfaceHolderClass, "getSurface", "()Landroid/view/Surface;");
jclass surfaceClass = env->FindClass("android/view/Surface");
gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
"mSurfacePointer", "I");
if (!gSurfaceJavaGlue.surfacePointer) {
CLEAR_EXCEPTION(env);
// It was something else in 2.2.
gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
"mSurface", "I");
if (!gSurfaceJavaGlue.surfacePointer) {
CLEAR_EXCEPTION(env);
// And something else in 2.3+
gSurfaceJavaGlue.surfacePointer = env->GetFieldID(surfaceClass,
"mNativeSurface", "I");
CLEAR_EXCEPTION(env);
}
}
if (!gSurfaceJavaGlue.surfacePointer) {
LOG("Failed to acquire surface pointer");
return nullptr;
}
env->DeleteLocalRef(surfaceClass);
env->DeleteLocalRef(surfaceViewClass);
env->DeleteLocalRef(surfaceHolderClass);
gSurfaceJavaGlue.initialized = (gSurfaceJavaGlue.surfacePointer != nullptr);
}
jobject holder = env->CallObjectMethod(view, gSurfaceJavaGlue.getSurfaceHolder);
jobject surface = env->CallObjectMethod(holder, gSurfaceJavaGlue.getSurface);
jint surfacePointer = env->GetIntField(surface, gSurfaceJavaGlue.surfacePointer);
env->DeleteLocalRef(holder);
env->DeleteLocalRef(surface);
return (void*)surfacePointer;
}
static ANPBitmapFormat convertPixelFormat(int32_t format) {
switch (format) {
case PIXEL_FORMAT_RGBA_8888: return kRGBA_8888_ANPBitmapFormat;
case PIXEL_FORMAT_RGB_565: return kRGB_565_ANPBitmapFormat;
default: return kUnknown_ANPBitmapFormat;
}
}
static int bytesPerPixel(int32_t format) {
switch (format) {
case PIXEL_FORMAT_RGBA_8888: return 4;
case PIXEL_FORMAT_RGB_565: return 2;
default: return -1;
}
}
static bool init() {
if (gSurfaceFunctions.initialized)
return true;
void* handle = dlopen("libsurfaceflinger_client.so", RTLD_LAZY);
if (!handle) {
LOG("Failed to open libsurfaceflinger_client.so");
return false;
}
gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionEb");
gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv");
if (!gSurfaceFunctions.lock) {
// Stuff changed in 3.0/4.0
handle = dlopen("libgui.so", RTLD_LAZY);
gSurfaceFunctions.lock = (int (*)(void*, SurfaceInfo*, void*))dlsym(handle, "_ZN7android7Surface4lockEPNS0_11SurfaceInfoEPNS_6RegionE");
gSurfaceFunctions.unlockAndPost = (int (*)(void*))dlsym(handle, "_ZN7android7Surface13unlockAndPostEv");
}
handle = dlopen("libui.so", RTLD_LAZY);
if (!handle) {
LOG("Failed to open libui.so");
return false;
}
gSurfaceFunctions.regionConstructor = (void* (*)(void*))dlsym(handle, "_ZN7android6RegionC1Ev");
gSurfaceFunctions.setRegion = (void (*)(void*, ARect const&))dlsym(handle, "_ZN7android6Region3setERKNS_4RectE");
gSurfaceFunctions.initialized = (gSurfaceFunctions.lock && gSurfaceFunctions.unlockAndPost &&
gSurfaceFunctions.regionConstructor && gSurfaceFunctions.setRegion);
LOG("Initialized? %d\n", gSurfaceFunctions.initialized);
return gSurfaceFunctions.initialized;
}
// FIXME: All of this should be changed to use the equivalent things in AndroidBridge, bug 758612
static bool anp_surface_lock(JNIEnv* env, jobject surfaceView, ANPBitmap* bitmap, ANPRectI* dirtyRect) {
if (!bitmap || !surfaceView) {
return false;
}
void* surface = getSurface(env, surfaceView);
if (!bitmap || !surface) {
return false;
}
if (!init()) {
return false;
}
void* region = nullptr;
if (dirtyRect) {
region = malloc(ANDROID_REGION_SIZE);
gSurfaceFunctions.regionConstructor(region);
ARect rect;
rect.left = dirtyRect->left;
rect.top = dirtyRect->top;
rect.right = dirtyRect->right;
rect.bottom = dirtyRect->bottom;
gSurfaceFunctions.setRegion(region, rect);
}
SurfaceInfo info;
int err = gSurfaceFunctions.lock(surface, &info, region);
if (err < 0) {
LOG("Failed to lock surface");
return false;
}
// the surface may have expanded the dirty region so we must to pass that
// information back to the plugin.
if (dirtyRect) {
ARect* dirtyBounds = (ARect*)region; // The bounds are the first member, so this should work!
dirtyRect->left = dirtyBounds->left;
dirtyRect->right = dirtyBounds->right;
dirtyRect->top = dirtyBounds->top;
dirtyRect->bottom = dirtyBounds->bottom;
}
if (region)
free(region);
int bpr = info.s * bytesPerPixel(info.format);
bitmap->format = convertPixelFormat(info.format);
bitmap->width = info.w;
bitmap->height = info.h;
bitmap->rowBytes = bpr;
if (info.w > 0 && info.h > 0) {
bitmap->baseAddr = info.bits;
} else {
bitmap->baseAddr = nullptr;
return false;
}
return true;
}
static void anp_surface_unlock(JNIEnv* env, jobject surfaceView) {
if (!surfaceView) {
return;
}
if (!init()) {
return;
}
void* surface = getSurface(env, surfaceView);
if (!surface) {
return;
}
gSurfaceFunctions.unlockAndPost(surface);
}
///////////////////////////////////////////////////////////////////////////////
void InitSurfaceInterface(ANPSurfaceInterfaceV0* i) {
ASSIGN(i, lock);
ASSIGN(i, unlock);
// setup the java glue struct
gSurfaceJavaGlue.initialized = false;
// setup the function struct
gSurfaceFunctions.initialized = false;
}

View file

@ -1,88 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "ANPBase.h"
#include "GeneratedJNIWrappers.h"
#include "PluginPRLibrary.h"
#include "assert.h"
#include "nsNPAPIPluginInstance.h"
#include "nsNPAPIPlugin.h"
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_system_##name
const char*
anp_system_getApplicationDataDirectory(NPP instance)
{
static const char *dir = nullptr;
static const char *privateDir = nullptr;
bool isPrivate = false;
if (!dir) {
dir = getenv("ANDROID_PLUGIN_DATADIR");
}
if (!privateDir) {
privateDir = getenv("ANDROID_PLUGIN_DATADIR_PRIVATE");
}
if (!instance) {
return dir;
}
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
if (pinst && NS_SUCCEEDED(pinst->IsPrivateBrowsing(&isPrivate)) && isPrivate) {
return privateDir;
}
return dir;
}
const char*
anp_system_getApplicationDataDirectory()
{
return anp_system_getApplicationDataDirectory(nullptr);
}
jclass anp_system_loadJavaClass(NPP instance, const char* className)
{
LOG("%s", __PRETTY_FUNCTION__);
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
mozilla::PluginPRLibrary* lib = static_cast<mozilla::PluginPRLibrary*>(pinst->GetPlugin()->GetLibrary());
nsCString libName;
lib->GetLibraryPath(libName);
return mozilla::java::GeckoAppShell::LoadPluginClass(className, libName).Forget();
}
void anp_system_setPowerState(NPP instance, ANPPowerState powerState)
{
nsNPAPIPluginInstance* pinst = nsNPAPIPluginInstance::GetFromNPP(instance);
if (pinst) {
pinst->SetWakeLock(powerState == kScreenOn_ANPPowerState);
}
}
void InitSystemInterfaceV1(ANPSystemInterfaceV1 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, getApplicationDataDirectory);
ASSIGN(i, loadJavaClass);
ASSIGN(i, setPowerState);
}
void InitSystemInterfaceV2(ANPSystemInterfaceV2 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, getApplicationDataDirectory);
ASSIGN(i, loadJavaClass);
ASSIGN(i, setPowerState);
}

View file

@ -1,55 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <android/log.h>
#include "ANPBase.h"
#include "nsIPluginInstanceOwner.h"
#include "nsPluginInstanceOwner.h"
#include "nsNPAPIPluginInstance.h"
#include "gfxRect.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_video_##name
using namespace mozilla;
typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
static ANPNativeWindow anp_video_acquireNativeWindow(NPP instance) {
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
return pinst->AcquireVideoWindow();
}
static void anp_video_setWindowDimensions(NPP instance, const ANPNativeWindow window,
const ANPRectF* dimensions) {
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
gfxRect rect(dimensions->left, dimensions->top,
dimensions->right - dimensions->left,
dimensions->bottom - dimensions->top);
pinst->SetVideoDimensions(window, rect);
pinst->RedrawPlugin();
}
static void anp_video_releaseNativeWindow(NPP instance, ANPNativeWindow window) {
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
pinst->ReleaseVideoWindow(window);
pinst->RedrawPlugin();
}
static void anp_video_setFramerateCallback(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc callback) {
// Bug 722682
NOT_IMPLEMENTED();
}
///////////////////////////////////////////////////////////////////////////////
void InitVideoInterfaceV1(ANPVideoInterfaceV1* i) {
ASSIGN(i, acquireNativeWindow);
ASSIGN(i, setWindowDimensions);
ASSIGN(i, releaseNativeWindow);
ASSIGN(i, setFramerateCallback);
}

View file

@ -1,152 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "assert.h"
#include "ANPBase.h"
#include <android/log.h>
#include "nsNPAPIPluginInstance.h"
#include "nsPluginInstanceOwner.h"
#include "nsWindow.h"
#include "mozilla/dom/ScreenOrientation.h"
#undef LOG
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#define ASSIGN(obj, name) (obj)->name = anp_window_##name
using namespace mozilla;
using namespace mozilla::widget;
using namespace mozilla::dom;
void
anp_window_setVisibleRects(NPP instance, const ANPRectI rects[], int32_t count)
{
NOT_IMPLEMENTED();
}
void
anp_window_clearVisibleRects(NPP instance)
{
NOT_IMPLEMENTED();
}
void
anp_window_showKeyboard(NPP instance, bool value)
{
InputContext context;
context.mIMEState.mEnabled = value ? IMEState::PLUGIN : IMEState::DISABLED;
context.mIMEState.mOpen = value ? IMEState::OPEN : IMEState::CLOSED;
context.mActionHint.Assign(EmptyString());
InputContextAction action;
action.mCause = InputContextAction::CAUSE_UNKNOWN;
action.mFocusChange = InputContextAction::FOCUS_NOT_CHANGED;
nsWindow* window = nsWindow::TopWindow();
if (!window) {
LOG("Couldn't get top window?");
return;
}
window->SetInputContext(context, action);
}
void
anp_window_requestFullScreen(NPP instance)
{
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
if (!owner) {
return;
}
owner->RequestFullScreen();
}
void
anp_window_exitFullScreen(NPP instance)
{
nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
RefPtr<nsPluginInstanceOwner> owner = inst->GetOwner();
if (!owner) {
return;
}
owner->ExitFullScreen();
}
void
anp_window_requestCenterFitZoom(NPP instance)
{
NOT_IMPLEMENTED();
}
ANPRectI
anp_window_visibleRect(NPP instance)
{
ANPRectI rect = { 0, 0, 0, 0 };
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
nsIntSize currentSize = pinst->CurrentSize();
rect.left = rect.top = 0;
rect.right = currentSize.width;
rect.bottom = currentSize.height;
return rect;
}
void anp_window_requestFullScreenOrientation(NPP instance, ANPScreenOrientation orientation)
{
short newOrientation;
// Convert to the ActivityInfo equivalent
switch (orientation) {
case kFixedLandscape_ANPScreenOrientation:
newOrientation = eScreenOrientation_LandscapePrimary;
break;
case kFixedPortrait_ANPScreenOrientation:
newOrientation = eScreenOrientation_PortraitPrimary;
break;
case kLandscape_ANPScreenOrientation:
newOrientation = eScreenOrientation_LandscapePrimary |
eScreenOrientation_LandscapeSecondary;
break;
case kPortrait_ANPScreenOrientation:
newOrientation = eScreenOrientation_PortraitPrimary |
eScreenOrientation_PortraitSecondary;
break;
default:
newOrientation = eScreenOrientation_None;
break;
}
nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
pinst->SetFullScreenOrientation(newOrientation);
}
void InitWindowInterface(ANPWindowInterfaceV0 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, setVisibleRects);
ASSIGN(i, clearVisibleRects);
ASSIGN(i, showKeyboard);
ASSIGN(i, requestFullScreen);
ASSIGN(i, exitFullScreen);
ASSIGN(i, requestCenterFitZoom);
}
void InitWindowInterfaceV2(ANPWindowInterfaceV2 *i) {
_assert(i->inSize == sizeof(*i));
ASSIGN(i, setVisibleRects);
ASSIGN(i, clearVisibleRects);
ASSIGN(i, showKeyboard);
ASSIGN(i, requestFullScreen);
ASSIGN(i, exitFullScreen);
ASSIGN(i, requestCenterFitZoom);
ASSIGN(i, visibleRect);
ASSIGN(i, requestFullScreenOrientation);
}

File diff suppressed because it is too large Load diff

View file

@ -1,35 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS += [
'android_npapi.h',
'ANPKeyCodes.h',
]
SOURCES += [
'ANPAudio.cpp',
'ANPEvent.cpp',
'ANPLog.cpp',
'ANPNativeWindow.cpp',
'ANPSurface.cpp',
'ANPSystem.cpp',
'ANPVideo.cpp',
'ANPWindow.cpp',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/dom/plugins/base',
'/gfx/gl',
'/widget',
'/widget/android',
]
DEFINES['MOZ_APP_NAME'] = '"%s"' % CONFIG['MOZ_APP_NAME']
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']

View file

@ -4,9 +4,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['android']
XPIDL_SOURCES += [ XPIDL_SOURCES += [
'nsIHTTPHeaderListener.idl', 'nsIHTTPHeaderListener.idl',
'nsIPluginDocument.idl', 'nsIPluginDocument.idl',
@ -89,16 +86,10 @@ LOCAL_INCLUDES += [
'/layout/xul', '/layout/xul',
'/netwerk/base', '/netwerk/base',
'/widget', '/widget',
'/widget/android',
'/widget/cocoa', '/widget/cocoa',
'/xpcom/base', '/xpcom/base',
] ]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
LOCAL_INCLUDES += [
'/dom/plugins/base/android',
]
if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['OS_ARCH'] == 'WINNT':
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [
'/xpcom/base', '/xpcom/base',
@ -106,8 +97,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
include('/ipc/chromium/chromium-config.mozbuild') include('/ipc/chromium/chromium-config.mozbuild')
DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
FINAL_LIBRARY = 'xul' FINAL_LIBRARY = 'xul'
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS'] CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']

View file

@ -9,10 +9,6 @@
#include "npapi.h" #include "npapi.h"
#include "npruntime.h" #include "npruntime.h"
#ifdef MOZ_WIDGET_ANDROID
#include <jni.h>
#endif
typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved); typedef NPError (* NPP_NewProcPtr)(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved);
typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save); typedef NPError (* NPP_DestroyProcPtr)(NPP instance, NPSavedData** save);
typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window); typedef NPError (* NPP_SetWindowProcPtr)(NPP instance, NPWindow* window);
@ -261,14 +257,9 @@ NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs);
typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*); typedef NPError (*NP_GetEntryPointsFunc)(NPPluginFuncs*);
NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs); NP_EXPORT(NPError) NP_GetEntryPoints(NPPluginFuncs* pFuncs);
#else #else
#ifdef MOZ_WIDGET_ANDROID
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*, JNIEnv* pEnv);
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, JNIEnv* pEnv);
#else
typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*); typedef NPError (*NP_InitializeFunc)(NPNetscapeFuncs*, NPPluginFuncs*);
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs); NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs);
#endif #endif
#endif
typedef NPError (*NP_ShutdownFunc)(void); typedef NPError (*NP_ShutdownFunc)(void);
NP_EXPORT(NPError) NP_Shutdown(void); NP_EXPORT(NPError) NP_Shutdown(void);
typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *); typedef NPError (*NP_GetValueFunc)(void *, NPPVariable, void *);

View file

@ -97,15 +97,6 @@ using mozilla::plugins::PluginModuleContentParent;
#endif #endif
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
#include <android/log.h>
#include "android_npapi.h"
#include "ANPBase.h"
#include "GeneratedJNIWrappers.h"
#undef LOG
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#endif
#include "nsIAudioChannelAgent.h" #include "nsIAudioChannelAgent.h"
#include "AudioChannelService.h" #include "AudioChannelService.h"
@ -236,11 +227,7 @@ nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
bool bool
nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
{ {
#ifdef MOZ_WIDGET_ANDROID
return false;
#else
return true; return true;
#endif
} }
inline PluginLibrary* inline PluginLibrary*
@ -282,7 +269,7 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin** aResult)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) #ifdef XP_MACOSX
if (!pluginLib->HasRequiredFunctions()) { if (!pluginLib->HasRequiredFunctions()) {
NS_WARNING("Not all necessary functions exposed by plugin, it will not load."); NS_WARNING("Not all necessary functions exposed by plugin, it will not load.");
delete pluginLib; delete pluginLib;
@ -2019,156 +2006,6 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
} }
#ifdef MOZ_WIDGET_ANDROID
case kLogInterfaceV0_ANPGetValue: {
LOG("get log interface");
ANPLogInterfaceV0 *i = (ANPLogInterfaceV0 *) result;
InitLogInterface(i);
return NPERR_NO_ERROR;
}
case kBitmapInterfaceV0_ANPGetValue: {
LOG("get bitmap interface");
return NPERR_GENERIC_ERROR;
}
case kMatrixInterfaceV0_ANPGetValue: {
LOG("get matrix interface");
return NPERR_GENERIC_ERROR;
}
case kPathInterfaceV0_ANPGetValue: {
LOG("get path interface");
return NPERR_GENERIC_ERROR;
}
case kTypefaceInterfaceV0_ANPGetValue: {
LOG("get typeface interface");
ANPTypefaceInterfaceV0 *i = (ANPTypefaceInterfaceV0 *) result;
InitTypeFaceInterface(i);
return NPERR_NO_ERROR;
}
case kPaintInterfaceV0_ANPGetValue: {
LOG("get paint interface");
ANPPaintInterfaceV0 *i = (ANPPaintInterfaceV0 *) result;
InitPaintInterface(i);
return NPERR_NO_ERROR;
}
case kCanvasInterfaceV0_ANPGetValue: {
LOG("get canvas interface");
ANPCanvasInterfaceV0 *i = (ANPCanvasInterfaceV0 *) result;
InitCanvasInterface(i);
return NPERR_NO_ERROR;
}
case kWindowInterfaceV0_ANPGetValue: {
LOG("get window interface");
ANPWindowInterfaceV0 *i = (ANPWindowInterfaceV0 *) result;
InitWindowInterface(i);
return NPERR_NO_ERROR;
}
case kAudioTrackInterfaceV0_ANPGetValue: {
LOG("get audio interface");
ANPAudioTrackInterfaceV0 *i = (ANPAudioTrackInterfaceV0 *) result;
InitAudioTrackInterfaceV0(i);
return NPERR_NO_ERROR;
}
case kEventInterfaceV0_ANPGetValue: {
LOG("get event interface");
ANPEventInterfaceV0 *i = (ANPEventInterfaceV0 *) result;
InitEventInterface(i);
return NPERR_NO_ERROR;
}
case kSystemInterfaceV0_ANPGetValue: {
LOG("get system interface");
return NPERR_GENERIC_ERROR;
}
case kSurfaceInterfaceV0_ANPGetValue: {
LOG("get surface interface");
ANPSurfaceInterfaceV0 *i = (ANPSurfaceInterfaceV0 *) result;
InitSurfaceInterface(i);
return NPERR_NO_ERROR;
}
case kSupportedDrawingModel_ANPGetValue: {
LOG("get supported drawing model");
return NPERR_GENERIC_ERROR;
}
case kJavaContext_ANPGetValue: {
LOG("get java context");
auto ret = java::GeckoAppShell::GetContext();
if (!ret)
return NPERR_GENERIC_ERROR;
*static_cast<jobject*>(result) = ret.Forget();
return NPERR_NO_ERROR;
}
case kAudioTrackInterfaceV1_ANPGetValue: {
LOG("get audio interface v1");
ANPAudioTrackInterfaceV1 *i = (ANPAudioTrackInterfaceV1 *) result;
InitAudioTrackInterfaceV1(i);
return NPERR_NO_ERROR;
}
case kNativeWindowInterfaceV0_ANPGetValue: {
LOG("get native window interface v0");
ANPNativeWindowInterfaceV0* i = (ANPNativeWindowInterfaceV0 *) result;
InitNativeWindowInterface(i);
return NPERR_NO_ERROR;
}
case kOpenGLInterfaceV0_ANPGetValue: {
LOG("get openGL interface");
return NPERR_GENERIC_ERROR;
}
case kWindowInterfaceV1_ANPGetValue: {
LOG("get Window interface V1");
return NPERR_GENERIC_ERROR;
}
case kWindowInterfaceV2_ANPGetValue: {
LOG("get Window interface V2");
ANPWindowInterfaceV2 *i = (ANPWindowInterfaceV2 *) result;
InitWindowInterfaceV2(i);
return NPERR_NO_ERROR;
}
case kVideoInterfaceV0_ANPGetValue: {
LOG("get video interface V0");
return NPERR_GENERIC_ERROR;
}
case kVideoInterfaceV1_ANPGetValue: {
LOG("get video interface V1");
ANPVideoInterfaceV1 *i = (ANPVideoInterfaceV1*) result;
InitVideoInterfaceV1(i);
return NPERR_NO_ERROR;
}
case kSystemInterfaceV1_ANPGetValue: {
LOG("get system interface v1");
ANPSystemInterfaceV1* i = reinterpret_cast<ANPSystemInterfaceV1*>(result);
InitSystemInterfaceV1(i);
return NPERR_NO_ERROR;
}
case kSystemInterfaceV2_ANPGetValue: {
LOG("get system interface v2");
ANPSystemInterfaceV2* i = reinterpret_cast<ANPSystemInterfaceV2*>(result);
InitSystemInterfaceV2(i);
return NPERR_NO_ERROR;
}
#endif
// we no longer hand out any XPCOM objects // we no longer hand out any XPCOM objects
case NPNVDOMElement: case NPNVDOMElement:
case NPNVDOMWindow: case NPNVDOMWindow:
@ -2298,8 +2135,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
} }
#ifndef MOZ_WIDGET_ANDROID
// On android, their 'drawing model' uses the same constant!
case NPPVpluginDrawingModel: { case NPPVpluginDrawingModel: {
if (inst) { if (inst) {
inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result)); inst->SetDrawingModel((NPDrawingModel)NS_PTR_TO_INT32(result));
@ -2309,7 +2144,6 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
} }
} }
#endif
#ifdef XP_MACOSX #ifdef XP_MACOSX
case NPPVpluginEventModel: { case NPPVpluginEventModel: {
@ -2322,14 +2156,7 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
} }
} }
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
case kRequestDrawingModel_ANPSetValue:
if (inst)
inst->SetANPDrawingModel(NS_PTR_TO_INT32(result));
return NPERR_NO_ERROR;
case kAcceptEvents_ANPSetValue:
return NPERR_NO_ERROR;
#endif
default: default:
return NPERR_GENERIC_ERROR; return NPERR_GENERIC_ERROR;
} }
@ -2682,13 +2509,8 @@ _unscheduletimer(NPP instance, uint32_t timerID)
return; return;
} }
#ifdef MOZ_WIDGET_ANDROID
// Sometimes Flash calls this with a dead NPP instance. Ensure the one we have
// here is valid and maps to a nsNPAPIPluginInstance.
nsNPAPIPluginInstance *inst = nsNPAPIPluginInstance::GetFromNPP(instance);
#else
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata; nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *)instance->ndata;
#endif
if (!inst) if (!inst)
return; return;

View file

@ -5,11 +5,6 @@
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#ifdef MOZ_WIDGET_ANDROID
// For ScreenOrientation.h and Hal.h
#include "base/basictypes.h"
#endif
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "prmem.h" #include "prmem.h"
#include "nscore.h" #include "nscore.h"
@ -45,64 +40,6 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include <android/log.h>
#include "android_npapi.h"
#include "mozilla/Mutex.h"
#include "mozilla/CondVar.h"
#include "mozilla/dom/ScreenOrientation.h"
#include "mozilla/Hal.h"
#include "GLContextProvider.h"
#include "GLContext.h"
#include "TexturePoolOGL.h"
#include "SurfaceTypes.h"
#include "EGLUtils.h"
using namespace mozilla;
using namespace mozilla::gl;
typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
class PluginEventRunnable : public Runnable
{
public:
PluginEventRunnable(nsNPAPIPluginInstance* instance, ANPEvent* event)
: mInstance(instance), mEvent(*event), mCanceled(false) {}
virtual nsresult Run() {
if (mCanceled)
return NS_OK;
mInstance->HandleEvent(&mEvent, nullptr);
mInstance->PopPostedEvent(this);
return NS_OK;
}
void Cancel() { mCanceled = true; }
private:
nsNPAPIPluginInstance* mInstance;
ANPEvent mEvent;
bool mCanceled;
};
static RefPtr<GLContext> sPluginContext = nullptr;
static bool EnsureGLContext()
{
if (!sPluginContext) {
const auto flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE;
nsCString discardedFailureId;
sPluginContext = GLContextProvider::CreateHeadless(flags, &discardedFailureId);
}
return sPluginContext != nullptr;
}
static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
#endif
using namespace mozilla; using namespace mozilla;
using namespace mozilla::plugins::parent; using namespace mozilla::plugins::parent;
using namespace mozilla::layers; using namespace mozilla::layers;
@ -113,13 +50,6 @@ NS_IMPL_ISUPPORTS(nsNPAPIPluginInstance, nsIAudioChannelAgentCallback)
nsNPAPIPluginInstance::nsNPAPIPluginInstance() nsNPAPIPluginInstance::nsNPAPIPluginInstance()
: mDrawingModel(kDefaultDrawingModel) : mDrawingModel(kDefaultDrawingModel)
#ifdef MOZ_WIDGET_ANDROID
, mANPDrawingModel(0)
, mFullScreenOrientation(dom::eScreenOrientation_LandscapePrimary)
, mWakeLocked(false)
, mFullScreen(false)
, mOriginPos(gl::OriginPos::TopLeft)
#endif
, mRunning(NOT_STARTED) , mRunning(NOT_STARTED)
, mWindowless(false) , mWindowless(false)
, mTransparent(false) , mTransparent(false)
@ -131,9 +61,6 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
, mOwner(nullptr) , mOwner(nullptr)
#ifdef XP_MACOSX #ifdef XP_MACOSX
, mCurrentPluginEvent(nullptr) , mCurrentPluginEvent(nullptr)
#endif
#ifdef MOZ_WIDGET_ANDROID
, mOnScreen(true)
#endif #endif
, mHaveJavaC2PJSObjectQuirk(false) , mHaveJavaC2PJSObjectQuirk(false)
, mCachedParamLength(0) , mCachedParamLength(0)
@ -145,20 +72,12 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
mNPP.ndata = this; mNPP.ndata = this;
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this)); PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
#ifdef MOZ_WIDGET_ANDROID
sPluginNPPMap[&mNPP] = this;
#endif
} }
nsNPAPIPluginInstance::~nsNPAPIPluginInstance() nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
{ {
PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this)); PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance dtor: this=%p\n",this));
#ifdef MOZ_WIDGET_ANDROID
sPluginNPPMap.erase(&mNPP);
#endif
if (mMIMEType) { if (mMIMEType) {
PR_Free((void *)mMIMEType); PR_Free((void *)mMIMEType);
mMIMEType = nullptr; mMIMEType = nullptr;
@ -195,21 +114,6 @@ nsNPAPIPluginInstance::Destroy()
Stop(); Stop();
mPlugin = nullptr; mPlugin = nullptr;
mAudioChannelAgent = nullptr; mAudioChannelAgent = nullptr;
#if MOZ_WIDGET_ANDROID
if (mContentSurface)
mContentSurface->SetFrameAvailableCallback(nullptr);
mContentSurface = nullptr;
std::map<void*, VideoInfo*>::iterator it;
for (it = mVideos.begin(); it != mVideos.end(); it++) {
it->second->mSurfaceTexture->SetFrameAvailableCallback(nullptr);
delete it->second;
}
mVideos.clear();
SetWakeLock(false);
#endif
} }
TimeStamp TimeStamp
@ -297,14 +201,6 @@ nsresult nsNPAPIPluginInstance::Stop()
} }
mRunning = DESTROYED; mRunning = DESTROYED;
#if MOZ_WIDGET_ANDROID
for (uint32_t i = 0; i < mPostedEvents.Length(); i++) {
mPostedEvents[i]->Cancel();
}
mPostedEvents.Clear();
#endif
nsJSNPRuntime::OnPluginDestroy(&mNPP); nsJSNPRuntime::OnPluginDestroy(&mNPP);
if (error != NPERR_NO_ERROR) if (error != NPERR_NO_ERROR)
@ -404,13 +300,8 @@ nsNPAPIPluginInstance::Start()
mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue); mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue);
} }
// Android expects and empty string instead of null.
mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM")); mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
#ifdef MOZ_WIDGET_ANDROID mCachedParamValues[attributes.Length()] = nullptr;
mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING(""));
#else
mCachedParamValues[attributes.Length()] = nullptr;
#endif
for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) { for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) {
mCachedParamNames[pos] = ToNewUTF8String(params[i].mName); mCachedParamNames[pos] = ToNewUTF8String(params[i].mName);
@ -738,249 +629,6 @@ void nsNPAPIPluginInstance::SetEventModel(NPEventModel aModel)
} }
#endif #endif
#if defined(MOZ_WIDGET_ANDROID)
static void SendLifecycleEvent(nsNPAPIPluginInstance* aInstance, uint32_t aAction)
{
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = kLifecycle_ANPEventType;
event.data.lifecycle.action = aAction;
aInstance->HandleEvent(&event, nullptr);
}
void nsNPAPIPluginInstance::NotifyForeground(bool aForeground)
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetForeground this=%p\n foreground=%d",this, aForeground));
if (RUNNING != mRunning)
return;
SendLifecycleEvent(this, aForeground ? kResume_ANPLifecycleAction : kPause_ANPLifecycleAction);
}
void nsNPAPIPluginInstance::NotifyOnScreen(bool aOnScreen)
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::SetOnScreen this=%p\n onScreen=%d",this, aOnScreen));
if (RUNNING != mRunning || mOnScreen == aOnScreen)
return;
mOnScreen = aOnScreen;
SendLifecycleEvent(this, aOnScreen ? kOnScreen_ANPLifecycleAction : kOffScreen_ANPLifecycleAction);
}
void nsNPAPIPluginInstance::MemoryPressure()
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::MemoryPressure this=%p\n",this));
if (RUNNING != mRunning)
return;
SendLifecycleEvent(this, kFreeMemory_ANPLifecycleAction);
}
void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::NotifyFullScreen this=%p\n",this));
if (RUNNING != mRunning || mFullScreen == aFullScreen)
return;
mFullScreen = aFullScreen;
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
}
}
void nsNPAPIPluginInstance::NotifySize(nsIntSize size)
{
if (kOpenGL_ANPDrawingModel != GetANPDrawingModel() ||
size == mCurrentSize)
return;
mCurrentSize = size;
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = kDraw_ANPEventType;
event.data.draw.model = kOpenGL_ANPDrawingModel;
event.data.draw.data.surfaceSize.width = size.width;
event.data.draw.data.surfaceSize.height = size.height;
HandleEvent(&event, nullptr);
}
void nsNPAPIPluginInstance::SetANPDrawingModel(uint32_t aModel)
{
mANPDrawingModel = aModel;
}
void* nsNPAPIPluginInstance::GetJavaSurface()
{
void* surface = nullptr;
nsresult rv = GetValueFromPlugin(kJavaSurface_ANPGetValue, &surface);
if (NS_FAILED(rv))
return nullptr;
return surface;
}
void nsNPAPIPluginInstance::PostEvent(void* event)
{
PluginEventRunnable *r = new PluginEventRunnable(this, (ANPEvent*)event);
mPostedEvents.AppendElement(RefPtr<PluginEventRunnable>(r));
NS_DispatchToMainThread(r);
}
void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation)
{
if (mFullScreenOrientation == orientation)
return;
uint32_t oldOrientation = mFullScreenOrientation;
mFullScreenOrientation = orientation;
if (mFullScreen) {
// We're already fullscreen so immediately apply the orientation change
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
java::GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
} else if (oldOrientation != dom::eScreenOrientation_None) {
// We applied an orientation when we entered fullscreen, but
// we don't want it anymore
java::GeckoAppShell::UnlockScreenOrientation();
}
}
}
void nsNPAPIPluginInstance::PopPostedEvent(PluginEventRunnable* r)
{
mPostedEvents.RemoveElement(r);
}
void nsNPAPIPluginInstance::SetWakeLock(bool aLocked)
{
if (aLocked == mWakeLocked)
return;
mWakeLocked = aLocked;
hal::ModifyWakeLock(NS_LITERAL_STRING("screen"),
mWakeLocked ? hal::WAKE_LOCK_ADD_ONE : hal::WAKE_LOCK_REMOVE_ONE,
hal::WAKE_LOCK_NO_CHANGE);
}
GLContext* nsNPAPIPluginInstance::GLContext()
{
if (!EnsureGLContext())
return nullptr;
return sPluginContext;
}
already_AddRefed<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
{
if (!EnsureGLContext())
return nullptr;
GLuint texture = TexturePoolOGL::AcquireTexture();
if (!texture)
return nullptr;
RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
texture);
if (!surface) {
return nullptr;
}
nsCOMPtr<nsIRunnable> frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
surface->SetFrameAvailableCallback(frameCallback);
return surface.forget();
}
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
{
if (mRunning == RUNNING && mOwner)
mOwner->Recomposite();
}
void* nsNPAPIPluginInstance::AcquireContentWindow()
{
if (!mContentSurface) {
mContentSurface = CreateSurfaceTexture();
if (!mContentSurface)
return nullptr;
}
return mContentSurface->NativeWindow();
}
AndroidSurfaceTexture*
nsNPAPIPluginInstance::AsSurfaceTexture()
{
if (!mContentSurface)
return nullptr;
return mContentSurface;
}
void* nsNPAPIPluginInstance::AcquireVideoWindow()
{
RefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
if (!surface) {
return nullptr;
}
VideoInfo* info = new VideoInfo(surface);
void* window = info->mSurfaceTexture->NativeWindow();
mVideos.insert(std::pair<void*, VideoInfo*>(window, info));
return window;
}
void nsNPAPIPluginInstance::ReleaseVideoWindow(void* window)
{
std::map<void*, VideoInfo*>::iterator it = mVideos.find(window);
if (it == mVideos.end())
return;
delete it->second;
mVideos.erase(window);
}
void nsNPAPIPluginInstance::SetVideoDimensions(void* window, gfxRect aDimensions)
{
std::map<void*, VideoInfo*>::iterator it;
it = mVideos.find(window);
if (it == mVideos.end())
return;
it->second->mDimensions = aDimensions;
}
void nsNPAPIPluginInstance::GetVideos(nsTArray<VideoInfo*>& aVideos)
{
std::map<void*, VideoInfo*>::iterator it;
for (it = mVideos.begin(); it != mVideos.end(); it++)
aVideos.AppendElement(it->second);
}
nsNPAPIPluginInstance* nsNPAPIPluginInstance::GetFromNPP(NPP npp)
{
std::map<NPP, nsNPAPIPluginInstance*>::iterator it;
it = sPluginNPPMap.find(npp);
if (it == sPluginNPPMap.end())
return nullptr;
return it->second;
}
#endif
nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel) nsresult nsNPAPIPluginInstance::GetDrawingModel(int32_t* aModel)
{ {
*aModel = (int32_t)mDrawingModel; *aModel = (int32_t)mDrawingModel;
@ -1083,9 +731,8 @@ nsNPAPIPluginInstance::ShouldCache()
nsresult nsresult
nsNPAPIPluginInstance::IsWindowless(bool* isWindowless) nsNPAPIPluginInstance::IsWindowless(bool* isWindowless)
{ {
#if defined(MOZ_WIDGET_ANDROID) || defined(XP_MACOSX) #ifdef XP_MACOSX
// All OS X plugins are windowless. // All OS X plugins are windowless.
// On android, pre-honeycomb, all plugins are treated as windowless.
*isWindowless = true; *isWindowless = true;
#else #else
*isWindowless = mWindowless; *isWindowless = mWindowless;

View file

@ -18,15 +18,6 @@
#include <prinrval.h> #include <prinrval.h>
#include "js/TypeDecls.h" #include "js/TypeDecls.h"
#include "nsIAudioChannelAgent.h" #include "nsIAudioChannelAgent.h"
#ifdef MOZ_WIDGET_ANDROID
#include "nsIRunnable.h"
#include "GLContextTypes.h"
#include "AndroidSurfaceTexture.h"
#include "AndroidBridge.h"
#include <map>
class PluginEventRunnable;
#endif
#include "mozilla/EventForwards.h" #include "mozilla/EventForwards.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "mozilla/PluginLibrary.h" #include "mozilla/PluginLibrary.h"
@ -163,90 +154,6 @@ public:
} }
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
void NotifyForeground(bool aForeground);
void NotifyOnScreen(bool aOnScreen);
void MemoryPressure();
void NotifyFullScreen(bool aFullScreen);
void NotifySize(nsIntSize size);
nsIntSize CurrentSize() { return mCurrentSize; }
bool IsOnScreen() {
return mOnScreen;
}
uint32_t GetANPDrawingModel() { return mANPDrawingModel; }
void SetANPDrawingModel(uint32_t aModel);
void* GetJavaSurface();
void PostEvent(void* event);
// These are really mozilla::dom::ScreenOrientation, but it's
// difficult to include that here
uint32_t FullScreenOrientation() { return mFullScreenOrientation; }
void SetFullScreenOrientation(uint32_t orientation);
void SetWakeLock(bool aLock);
mozilla::gl::GLContext* GLContext();
// For ANPOpenGL
class TextureInfo {
public:
TextureInfo() :
mTexture(0), mWidth(0), mHeight(0), mInternalFormat(0)
{
}
TextureInfo(GLuint aTexture, int32_t aWidth, int32_t aHeight, GLuint aInternalFormat) :
mTexture(aTexture), mWidth(aWidth), mHeight(aHeight), mInternalFormat(aInternalFormat)
{
}
GLuint mTexture;
int32_t mWidth;
int32_t mHeight;
GLuint mInternalFormat;
};
// For ANPNativeWindow
void* AcquireContentWindow();
mozilla::gl::AndroidSurfaceTexture* AsSurfaceTexture();
// For ANPVideo
class VideoInfo {
public:
VideoInfo(mozilla::gl::AndroidSurfaceTexture* aSurfaceTexture) :
mSurfaceTexture(aSurfaceTexture)
{
}
~VideoInfo()
{
mSurfaceTexture = nullptr;
}
RefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
gfxRect mDimensions;
};
void* AcquireVideoWindow();
void ReleaseVideoWindow(void* aWindow);
void SetVideoDimensions(void* aWindow, gfxRect aDimensions);
void GetVideos(nsTArray<VideoInfo*>& aVideos);
void SetOriginPos(mozilla::gl::OriginPos aOriginPos) {
mOriginPos = aOriginPos;
}
mozilla::gl::OriginPos OriginPos() const { return mOriginPos; }
static nsNPAPIPluginInstance* GetFromNPP(NPP npp);
#endif
nsresult NewStreamListener(const char* aURL, void* notifyData, nsresult NewStreamListener(const char* aURL, void* notifyData,
nsNPAPIPluginStreamListener** listener); nsNPAPIPluginStreamListener** listener);
@ -347,23 +254,6 @@ protected:
NPDrawingModel mDrawingModel; NPDrawingModel mDrawingModel;
#ifdef MOZ_WIDGET_ANDROID
uint32_t mANPDrawingModel;
friend class PluginEventRunnable;
nsTArray<RefPtr<PluginEventRunnable>> mPostedEvents;
void PopPostedEvent(PluginEventRunnable* r);
void OnSurfaceTextureFrameAvailable();
uint32_t mFullScreenOrientation;
bool mWakeLocked;
bool mFullScreen;
mozilla::gl::OriginPos mOriginPos;
RefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
#endif
enum { enum {
NOT_STARTED, NOT_STARTED,
RUNNING, RUNNING,
@ -410,15 +300,6 @@ private:
// This is only valid when the plugin is actually stopped! // This is only valid when the plugin is actually stopped!
mozilla::TimeStamp mStopTime; mozilla::TimeStamp mStopTime;
#ifdef MOZ_WIDGET_ANDROID
already_AddRefed<mozilla::gl::AndroidSurfaceTexture> CreateSurfaceTexture();
std::map<void*, VideoInfo*> mVideos;
bool mOnScreen;
nsIntSize mCurrentSize;
#endif
// is this instance Java and affected by bug 750480? // is this instance Java and affected by bug 750480?
bool mHaveJavaC2PJSObjectQuirk; bool mHaveJavaC2PJSObjectQuirk;
@ -434,13 +315,7 @@ private:
bool mMuted; bool mMuted;
}; };
// On Android, we need to guard against plugin code leaking entries in the local #define MAIN_THREAD_JNI_REF_GUARD
// JNI ref table. See https://bugzilla.mozilla.org/show_bug.cgi?id=780831#c21
#ifdef MOZ_WIDGET_ANDROID
#define MAIN_THREAD_JNI_REF_GUARD mozilla::AutoLocalJNIFrame jniFrame
#else
#define MAIN_THREAD_JNI_REF_GUARD
#endif
void NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState); void NS_NotifyBeginPluginCall(NSPluginCallReentry aReentryState);
void NS_NotifyPluginCall(NSPluginCallReentry aReentryState); void NS_NotifyPluginCall(NSPluginCallReentry aReentryState);

View file

@ -104,11 +104,6 @@
#include "winbase.h" #include "winbase.h"
#endif #endif
#ifdef ANDROID
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#endif
#include "npapi.h" #include "npapi.h"
using namespace mozilla; using namespace mozilla;
@ -293,10 +288,6 @@ nsPluginHost::nsPluginHost()
if (obsService) { if (obsService) {
obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); obsService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
obsService->AddObserver(this, "blocklist-updated", false); obsService->AddObserver(this, "blocklist-updated", false);
#ifdef MOZ_WIDGET_ANDROID
obsService->AddObserver(this, "application-foreground", false);
obsService->AddObserver(this, "application-background", false);
#endif
} }
#ifdef PLUGIN_LOGGING #ifdef PLUGIN_LOGGING
@ -2306,11 +2297,6 @@ WatchRegKey(uint32_t aRoot, nsCOMPtr<nsIWindowsRegKey>& aKey)
nsresult nsPluginHost::LoadPlugins() nsresult nsPluginHost::LoadPlugins()
{ {
#ifdef ANDROID
if (XRE_IsContentProcess()) {
return NS_OK;
}
#endif
// do not do anything if it is already done // do not do anything if it is already done
// use ReloadPlugins() to enforce loading // use ReloadPlugins() to enforce loading
if (mPluginsLoaded) if (mPluginsLoaded)
@ -2453,10 +2439,6 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange
NS_ITERATIVE_UNREF_LIST(RefPtr<nsInvalidPluginTag>, mInvalidPlugins, mNext); NS_ITERATIVE_UNREF_LIST(RefPtr<nsInvalidPluginTag>, mInvalidPlugins, mNext);
return NS_OK; return NS_OK;
} }
} else {
#ifdef ANDROID
LOG("getting plugins dir failed");
#endif
} }
mPluginsLoaded = true; // at this point 'some' plugins have been loaded, mPluginsLoaded = true; // at this point 'some' plugins have been loaded,
@ -3069,14 +3051,6 @@ nsPluginHost::ReadPluginInfo()
if (!reader.NextLine()) if (!reader.NextLine())
return rv; return rv;
#if MOZ_WIDGET_ANDROID
// Flash on Android does not populate the version field, but it is tacked on to the description.
// For example, "Shockwave Flash 11.1 r115"
if (PL_strncmp("Shockwave Flash ", description, 16) == 0 && description[16]) {
version = &description[16];
}
#endif
const char *name = reader.LinePtr(); const char *name = reader.LinePtr();
if (!reader.NextLine()) if (!reader.NextLine())
return rv; return rv;
@ -3144,31 +3118,6 @@ nsPluginHost::ReadPluginInfo()
mCachedPlugins = tag; mCachedPlugins = tag;
} }
// On Android we always want to try to load a plugin again (Flash). Bug 935676.
#ifndef MOZ_WIDGET_ANDROID
if (!ReadSectionHeader(reader, "INVALID")) {
return rv;
}
while (reader.NextLine()) {
const char *fullpath = reader.LinePtr();
if (!reader.NextLine()) {
return rv;
}
const char *lastModifiedTimeStamp = reader.LinePtr();
int64_t lastmod = nsCRT::atoll(lastModifiedTimeStamp);
RefPtr<nsInvalidPluginTag> invalidTag = new nsInvalidPluginTag(fullpath, lastmod);
invalidTag->mNext = mInvalidPlugins;
if (mInvalidPlugins) {
mInvalidPlugins->mPrev = invalidTag;
}
mInvalidPlugins = invalidTag;
}
#endif
return NS_OK; return NS_OK;
} }
@ -3491,24 +3440,7 @@ NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject,
plugin = plugin->mNext; plugin = plugin->mNext;
} }
} }
#ifdef MOZ_WIDGET_ANDROID
if (!strcmp("application-background", aTopic)) {
for(uint32_t i = 0; i < mInstances.Length(); i++) {
mInstances[i]->NotifyForeground(false);
}
}
if (!strcmp("application-foreground", aTopic)) {
for(uint32_t i = 0; i < mInstances.Length(); i++) {
if (mInstances[i]->IsOnScreen())
mInstances[i]->NotifyForeground(true);
}
}
if (!strcmp("memory-pressure", aTopic)) {
for(uint32_t i = 0; i < mInstances.Length(); i++) {
mInstances[i]->MemoryPressure();
}
}
#endif
return NS_OK; return NS_OK;
} }

View file

@ -87,20 +87,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
#include "ANPBase.h"
#include "AndroidBridge.h"
#include "ClientLayerManager.h"
#include "nsWindow.h"
static nsPluginInstanceOwner* sFullScreenInstance = nullptr;
using namespace mozilla::dom;
#include <android/log.h>
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
#endif
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
using namespace mozilla::layers; using namespace mozilla::layers;
@ -165,29 +151,6 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder)
} }
} }
#if MOZ_WIDGET_ANDROID
static void
AttachToContainerAsSurfaceTexture(ImageContainer* container,
nsNPAPIPluginInstance* instance,
const LayoutDeviceRect& rect,
RefPtr<Image>* out_image)
{
MOZ_ASSERT(out_image);
MOZ_ASSERT(!*out_image);
mozilla::gl::AndroidSurfaceTexture* surfTex = instance->AsSurfaceTexture();
if (!surfTex) {
return;
}
RefPtr<Image> img = new SurfaceTextureImage(
surfTex,
gfx::IntSize::Truncate(rect.width, rect.height),
instance->OriginPos());
*out_image = img;
}
#endif
bool bool
nsPluginInstanceOwner::NeedsScrollImageLayer() nsPluginInstanceOwner::NeedsScrollImageLayer()
{ {
@ -211,27 +174,6 @@ nsPluginInstanceOwner::GetImageContainer()
RefPtr<ImageContainer> container; RefPtr<ImageContainer> container;
#if MOZ_WIDGET_ANDROID
LayoutDeviceRect r = GetPluginRect();
// NotifySize() causes Flash to do a bunch of stuff like ask for surfaces to render
// into, set y-flip flags, etc, so we do this at the beginning.
float resolution = mPluginFrame->PresContext()->PresShell()->GetCumulativeResolution();
ScreenSize screenSize = (r * LayoutDeviceToScreenScale(resolution)).Size();
mInstance->NotifySize(nsIntSize::Truncate(screenSize.width, screenSize.height));
container = LayerManager::CreateImageContainer();
if (r.width && r.height) {
// Try to get it as an EGLImage first.
RefPtr<Image> img;
AttachToContainerAsSurfaceTexture(container, mInstance, r, &img);
if (img) {
container->SetCurrentImageInTransaction(img);
}
}
#else
if (NeedsScrollImageLayer()) { if (NeedsScrollImageLayer()) {
// windowed plugin under e10s // windowed plugin under e10s
#if defined(XP_WIN) #if defined(XP_WIN)
@ -241,7 +183,6 @@ nsPluginInstanceOwner::GetImageContainer()
// async windowless rendering // async windowless rendering
mInstance->GetImageContainer(getter_AddRefs(container)); mInstance->GetImageContainer(getter_AddRefs(container));
} }
#endif
return container.forget(); return container.forget();
} }
@ -358,11 +299,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
mWaitingForPaint = false; mWaitingForPaint = false;
#ifdef MOZ_WIDGET_ANDROID
mFullScreen = false;
mJavaView = nullptr;
#endif
#ifdef XP_WIN #ifdef XP_WIN
mGotCompositionData = false; mGotCompositionData = false;
mSentStartComposition = false; mSentStartComposition = false;
@ -387,10 +323,6 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
PLUG_DeletePluginNativeWindow(mPluginWindow); PLUG_DeletePluginNativeWindow(mPluginWindow);
mPluginWindow = nullptr; mPluginWindow = nullptr;
#ifdef MOZ_WIDGET_ANDROID
RemovePluginView();
#endif
if (mInstance) { if (mInstance) {
mInstance->SetOwner(nullptr); mInstance->SetOwner(nullptr);
} }
@ -413,10 +345,6 @@ nsPluginInstanceOwner::SetInstance(nsNPAPIPluginInstance *aInstance)
// from our destructor. This fixes bug 613376. // from our destructor. This fixes bug 613376.
if (mInstance && !aInstance) { if (mInstance && !aInstance) {
mInstance->SetOwner(nullptr); mInstance->SetOwner(nullptr);
#ifdef MOZ_WIDGET_ANDROID
RemovePluginView();
#endif
} }
mInstance = aInstance; mInstance = aInstance;
@ -601,7 +529,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
if (!mPluginFrame || !invalidRect || !mWidgetVisible) if (!mPluginFrame || !invalidRect || !mWidgetVisible)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
#if defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) #ifdef XP_MACOSX
// Each time an asynchronously-drawing plugin sends a new surface to display, // Each time an asynchronously-drawing plugin sends a new surface to display,
// the image in the ImageContainer is updated and InvalidateRect is called. // the image in the ImageContainer is updated and InvalidateRect is called.
// There are different side effects for (sync) Android plugins. // There are different side effects for (sync) Android plugins.
@ -624,6 +552,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
} }
} }
#endif #endif
nsIntRect rect(invalidRect->left, nsIntRect rect(invalidRect->left,
invalidRect->top, invalidRect->top,
invalidRect->right - invalidRect->left, invalidRect->right - invalidRect->left,
@ -1485,185 +1414,6 @@ nsPluginInstanceOwner::GetEventloopNestingLevel()
return currentLevel; return currentLevel;
} }
#ifdef MOZ_WIDGET_ANDROID
// Modified version of nsFrame::GetOffsetToCrossDoc that stops when it
// hits an element with a displayport (or runs out of frames). This is
// not really the right thing to do, but it's better than what was here before.
static nsPoint
GetOffsetRootContent(nsIFrame* aFrame)
{
// offset will hold the final offset
// docOffset holds the currently accumulated offset at the current APD, it
// will be converted and added to offset when the current APD changes.
nsPoint offset(0, 0), docOffset(0, 0);
const nsIFrame* f = aFrame;
int32_t currAPD = aFrame->PresContext()->AppUnitsPerDevPixel();
int32_t apd = currAPD;
while (f) {
if (f->GetContent() && nsLayoutUtils::HasDisplayPort(f->GetContent()))
break;
docOffset += f->GetPosition();
nsIFrame* parent = f->GetParent();
if (parent) {
f = parent;
} else {
nsPoint newOffset(0, 0);
f = nsLayoutUtils::GetCrossDocParentFrame(f, &newOffset);
int32_t newAPD = f ? f->PresContext()->AppUnitsPerDevPixel() : 0;
if (!f || newAPD != currAPD) {
// Convert docOffset to the right APD and add it to offset.
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);
docOffset.x = docOffset.y = 0;
}
currAPD = newAPD;
docOffset += newOffset;
}
}
offset += docOffset.ScaleToOtherAppUnits(currAPD, apd);
return offset;
}
LayoutDeviceRect nsPluginInstanceOwner::GetPluginRect()
{
// Get the offset of the content relative to the page
nsRect bounds = mPluginFrame->GetContentRectRelativeToSelf() + GetOffsetRootContent(mPluginFrame);
LayoutDeviceIntRect rect = LayoutDeviceIntRect::FromAppUnitsToNearest(bounds, mPluginFrame->PresContext()->AppUnitsPerDevPixel());
return LayoutDeviceRect(rect);
}
bool nsPluginInstanceOwner::AddPluginView(const LayoutDeviceRect& aRect /* = LayoutDeviceRect(0, 0, 0, 0) */)
{
if (!mJavaView) {
mJavaView = mInstance->GetJavaSurface();
if (!mJavaView)
return false;
mJavaView = (void*)jni::GetGeckoThreadEnv()->NewGlobalRef((jobject)mJavaView);
}
if (mFullScreen) {
java::GeckoAppShell::AddFullScreenPluginView(jni::Object::Ref::From(jobject(mJavaView)));
sFullScreenInstance = this;
}
return true;
}
void nsPluginInstanceOwner::RemovePluginView()
{
if (!mInstance || !mJavaView)
return;
if (mFullScreen) {
java::GeckoAppShell::RemoveFullScreenPluginView(jni::Object::Ref::From(jobject(mJavaView)));
}
jni::GetGeckoThreadEnv()->DeleteGlobalRef((jobject)mJavaView);
mJavaView = nullptr;
if (mFullScreen)
sFullScreenInstance = nullptr;
}
void
nsPluginInstanceOwner::GetVideos(nsTArray<nsNPAPIPluginInstance::VideoInfo*>& aVideos)
{
if (!mInstance)
return;
mInstance->GetVideos(aVideos);
}
already_AddRefed<ImageContainer>
nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo)
{
RefPtr<ImageContainer> container = LayerManager::CreateImageContainer();
if (aVideoInfo->mDimensions.width && aVideoInfo->mDimensions.height) {
RefPtr<Image> img = new SurfaceTextureImage(
aVideoInfo->mSurfaceTexture,
gfx::IntSize::Truncate(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height),
gl::OriginPos::BottomLeft);
container->SetCurrentImageInTransaction(img);
}
return container.forget();
}
void nsPluginInstanceOwner::Invalidate() {
NPRect rect;
rect.left = rect.top = 0;
rect.right = mPluginWindow->width;
rect.bottom = mPluginWindow->height;
InvalidateRect(&rect);
}
void nsPluginInstanceOwner::Recomposite() {
nsIWidget* const widget = mPluginFrame->GetNearestWidget();
NS_ENSURE_TRUE_VOID(widget);
LayerManager* const lm = widget->GetLayerManager();
NS_ENSURE_TRUE_VOID(lm);
ClientLayerManager* const clm = lm->AsClientLayerManager();
NS_ENSURE_TRUE_VOID(clm && clm->GetRoot());
clm->SendInvalidRegion(
clm->GetRoot()->GetLocalVisibleRegion().ToUnknownRegion().GetBounds());
clm->Composite();
}
void nsPluginInstanceOwner::RequestFullScreen() {
if (mFullScreen)
return;
// Remove whatever view we currently have (if any, fullscreen or otherwise)
RemovePluginView();
mFullScreen = true;
AddPluginView();
mInstance->NotifyFullScreen(mFullScreen);
}
void nsPluginInstanceOwner::ExitFullScreen() {
if (!mFullScreen)
return;
RemovePluginView();
mFullScreen = false;
int32_t model = mInstance->GetANPDrawingModel();
if (model == kSurface_ANPDrawingModel) {
// We need to do this immediately, otherwise Flash
// sometimes causes a deadlock (bug 762407)
AddPluginView(GetPluginRect());
}
mInstance->NotifyFullScreen(mFullScreen);
// This will cause Paint() to be called, which is where
// we normally add/update views and layers
Invalidate();
}
void nsPluginInstanceOwner::ExitFullScreen(jobject view) {
JNIEnv* env = jni::GetGeckoThreadEnv();
if (sFullScreenInstance && sFullScreenInstance->mInstance &&
env->IsSameObject(view, (jobject)sFullScreenInstance->mInstance->GetJavaSurface())) {
sFullScreenInstance->ExitFullScreen();
}
}
#endif
void void
nsPluginInstanceOwner::NotifyHostAsyncInitFailed() nsPluginInstanceOwner::NotifyHostAsyncInitFailed()
{ {
@ -1705,27 +1455,6 @@ nsPluginInstanceOwner::NotifyDestroyPending()
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent) nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
{ {
#ifdef MOZ_WIDGET_ANDROID
if (mInstance) {
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = kLifecycle_ANPEventType;
nsAutoString eventType;
aFocusEvent->GetType(eventType);
if (eventType.EqualsLiteral("focus")) {
event.data.lifecycle.action = kGainFocus_ANPLifecycleAction;
}
else if (eventType.EqualsLiteral("blur")) {
event.data.lifecycle.action = kLoseFocus_ANPLifecycleAction;
}
else {
NS_ASSERTION(false, "nsPluginInstanceOwner::DispatchFocusToPlugin, wierd eventType");
}
mInstance->HandleEvent(&event, nullptr);
}
#endif
#ifndef XP_MACOSX #ifndef XP_MACOSX
if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) { if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
// continue only for cases without child window // continue only for cases without child window
@ -2786,96 +2515,6 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
rv = nsEventStatus_eConsumeNoDefault; rv = nsEventStatus_eConsumeNoDefault;
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
// this code supports windowless plugins
{
// The plugin needs focus to receive keyboard and touch events
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm) {
nsCOMPtr<nsIDOMElement> elem = do_QueryReferent(mContent);
fm->SetFocus(elem, 0);
}
}
switch(anEvent.mClass) {
case eMouseEventClass:
{
switch (anEvent.mMessage) {
case eMouseClick:
case eMouseDoubleClick:
case eMouseAuxClick:
// Button up/down events sent instead.
return rv;
default:
break;
}
// Get reference point relative to plugin origin.
const nsPresContext* presContext = mPluginFrame->PresContext();
nsPoint appPoint =
nsLayoutUtils::GetEventCoordinatesRelativeTo(&anEvent, mPluginFrame) -
mPluginFrame->GetContentRectRelativeToSelf().TopLeft();
nsIntPoint pluginPoint(presContext->AppUnitsToDevPixels(appPoint.x),
presContext->AppUnitsToDevPixels(appPoint.y));
switch (anEvent.mMessage) {
case eMouseMove:
{
// are these going to be touch events?
// pluginPoint.x;
// pluginPoint.y;
}
break;
case eMouseDown:
{
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = kMouse_ANPEventType;
event.data.mouse.action = kDown_ANPMouseAction;
event.data.mouse.x = pluginPoint.x;
event.data.mouse.y = pluginPoint.y;
mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
}
break;
case eMouseUp:
{
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = kMouse_ANPEventType;
event.data.mouse.action = kUp_ANPMouseAction;
event.data.mouse.x = pluginPoint.x;
event.data.mouse.y = pluginPoint.y;
mInstance->HandleEvent(&event, nullptr, NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
}
break;
default:
break;
}
}
break;
case eKeyboardEventClass:
{
const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent();
LOG("Firing eKeyboardEventClass %d %d\n",
keyEvent.mKeyCode, keyEvent.mCharCode);
// pluginEvent is initialized by nsWindow::InitKeyEvent().
const ANPEvent* pluginEvent = static_cast<const ANPEvent*>(keyEvent.mPluginEvent);
if (pluginEvent) {
MOZ_ASSERT(pluginEvent->inSize == sizeof(ANPEvent));
MOZ_ASSERT(pluginEvent->eventType == kKey_ANPEventType);
mInstance->HandleEvent(const_cast<ANPEvent*>(pluginEvent),
nullptr,
NS_PLUGIN_CALL_SAFE_TO_REENTER_GECKO);
}
}
break;
default:
break;
}
rv = nsEventStatus_eConsumeNoDefault;
#endif
return rv; return rv;
} }
@ -2922,10 +2561,6 @@ nsPluginInstanceOwner::Destroy()
this, true); this, true);
content->RemoveSystemEventListener(NS_LITERAL_STRING("text"), this, true); content->RemoveSystemEventListener(NS_LITERAL_STRING("text"), this, true);
#if MOZ_WIDGET_ANDROID
RemovePluginView();
#endif
if (mWidget) { if (mWidget) {
if (mPluginWindow) { if (mPluginWindow) {
mPluginWindow->SetPluginWidget(nullptr); mPluginWindow->SetPluginWidget(nullptr);
@ -2995,72 +2630,6 @@ void nsPluginInstanceOwner::Paint(const RECT& aDirty, HDC aDC)
} }
#endif #endif
#ifdef MOZ_WIDGET_ANDROID
void nsPluginInstanceOwner::Paint(gfxContext* aContext,
const gfxRect& aFrameRect,
const gfxRect& aDirtyRect)
{
if (!mInstance || !mPluginFrame || !mPluginDocumentActiveState || mFullScreen)
return;
int32_t model = mInstance->GetANPDrawingModel();
if (model == kSurface_ANPDrawingModel) {
if (!AddPluginView(GetPluginRect())) {
Invalidate();
}
return;
}
if (model != kBitmap_ANPDrawingModel)
return;
#ifdef ANP_BITMAP_DRAWING_MODEL
static RefPtr<gfxImageSurface> pluginSurface;
if (pluginSurface == nullptr ||
aFrameRect.width != pluginSurface->Width() ||
aFrameRect.height != pluginSurface->Height()) {
pluginSurface = new gfxImageSurface(gfx::IntSize(aFrameRect.width, aFrameRect.height),
SurfaceFormat::A8R8G8B8_UINT32);
if (!pluginSurface)
return;
}
// Clears buffer. I think this is needed.
gfxUtils::ClearThebesSurface(pluginSurface);
ANPEvent event;
event.inSize = sizeof(ANPEvent);
event.eventType = 4;
event.data.draw.model = 1;
event.data.draw.clip.top = 0;
event.data.draw.clip.left = 0;
event.data.draw.clip.bottom = aFrameRect.width;
event.data.draw.clip.right = aFrameRect.height;
event.data.draw.data.bitmap.format = kRGBA_8888_ANPBitmapFormat;
event.data.draw.data.bitmap.width = aFrameRect.width;
event.data.draw.data.bitmap.height = aFrameRect.height;
event.data.draw.data.bitmap.baseAddr = pluginSurface->Data();
event.data.draw.data.bitmap.rowBytes = aFrameRect.width * 4;
if (!mInstance)
return;
mInstance->HandleEvent(&event, nullptr);
aContext->SetOp(gfx::CompositionOp::OP_SOURCE);
aContext->SetSource(pluginSurface, gfxPoint(aFrameRect.x, aFrameRect.y));
aContext->Clip(aFrameRect);
aContext->Paint();
#endif
}
#endif
#if defined(MOZ_X11) #if defined(MOZ_X11)
void nsPluginInstanceOwner::Paint(gfxContext* aContext, void nsPluginInstanceOwner::Paint(gfxContext* aContext,
const gfxRect& aFrameRect, const gfxRect& aFrameRect,
@ -3663,24 +3232,6 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive)
#ifndef XP_MACOSX #ifndef XP_MACOSX
UpdateWindowPositionAndClipRect(true); UpdateWindowPositionAndClipRect(true);
#ifdef MOZ_WIDGET_ANDROID
if (mInstance) {
if (!mPluginDocumentActiveState) {
RemovePluginView();
}
mInstance->NotifyOnScreen(mPluginDocumentActiveState);
// This is, perhaps, incorrect. It is supposed to be sent
// when "the webview has paused or resumed". The side effect
// is that Flash video players pause or resume (if they were
// playing before) based on the value here. I personally think
// we want that on Android when switching to another tab, so
// that's why we call it here.
mInstance->NotifyForeground(mPluginDocumentActiveState);
}
#endif // #ifdef MOZ_WIDGET_ANDROID
// We don't have a connection to PluginWidgetParent in the chrome // We don't have a connection to PluginWidgetParent in the chrome
// process when dealing with tab visibility changes, so this needs // process when dealing with tab visibility changes, so this needs
// to be forwarded over after the active state is updated. If we // to be forwarded over after the active state is updated. If we

View file

@ -29,7 +29,7 @@ class nsPluginDOMContextMenuListener;
class nsPluginFrame; class nsPluginFrame;
class nsDisplayListBuilder; class nsDisplayListBuilder;
#if defined(MOZ_X11) || defined(ANDROID) #ifdef MOZ_X11
class gfxContext; class gfxContext;
#endif #endif
@ -108,7 +108,7 @@ public:
void Paint(const gfxRect& aDirtyRect, CGContextRef cgContext); void Paint(const gfxRect& aDirtyRect, CGContextRef cgContext);
void RenderCoreAnimation(CGContextRef aCGContext, int aWidth, int aHeight); void RenderCoreAnimation(CGContextRef aCGContext, int aWidth, int aHeight);
void DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext); void DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext);
#elif defined(MOZ_X11) || defined(ANDROID) #elif defined(MOZ_X11)
void Paint(gfxContext* aContext, void Paint(gfxContext* aContext,
const gfxRect& aFrameRect, const gfxRect& aFrameRect,
const gfxRect& aDirtyRect); const gfxRect& aDirtyRect);
@ -254,21 +254,6 @@ public:
already_AddRefed<nsIURI> GetBaseURI() const; already_AddRefed<nsIURI> GetBaseURI() const;
#ifdef MOZ_WIDGET_ANDROID
// Returns the image container for the specified VideoInfo
void GetVideos(nsTArray<nsNPAPIPluginInstance::VideoInfo*>& aVideos);
already_AddRefed<mozilla::layers::ImageContainer> GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInfo* aVideoInfo);
void Invalidate();
void Recomposite();
void RequestFullScreen();
void ExitFullScreen();
// Called from nsAppShell when we removed the fullscreen view.
static void ExitFullScreen(jobject view);
#endif
void NotifyHostAsyncInitFailed(); void NotifyHostAsyncInitFailed();
void NotifyHostCreateWidget(); void NotifyHostCreateWidget();
void NotifyDestroyPending(); void NotifyDestroyPending();
@ -306,16 +291,7 @@ private:
size == nsIntSize(mPluginWindow->width, mPluginWindow->height); size == nsIntSize(mPluginWindow->width, mPluginWindow->height);
} }
#ifdef MOZ_WIDGET_ANDROID #ifdef XP_WIN
mozilla::LayoutDeviceRect GetPluginRect();
bool AddPluginView(const mozilla::LayoutDeviceRect& aRect = mozilla::LayoutDeviceRect(0, 0, 0, 0));
void RemovePluginView();
bool mFullScreen;
void* mJavaView;
#endif
#if defined(XP_WIN)
nsIWidget* GetContainingWidgetIfOffset(); nsIWidget* GetContainingWidgetIfOffset();
already_AddRefed<mozilla::TextComposition> GetTextComposition(); already_AddRefed<mozilla::TextComposition> GetTextComposition();
void HandleNoConsumedCompositionMessage( void HandleNoConsumedCompositionMessage(

View file

@ -735,10 +735,6 @@ nsPluginTag::GetNiceName(nsACString & aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsPluginTag::GetBlocklistState(uint32_t *aResult) nsPluginTag::GetBlocklistState(uint32_t *aResult)
{ {
#if defined(MOZ_WIDGET_ANDROID)
*aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
return NS_OK;
#else
if (mCachedBlocklistStateValid) { if (mCachedBlocklistStateValid) {
*aResult = mCachedBlocklistState; *aResult = mCachedBlocklistState;
return NS_OK; return NS_OK;
@ -772,7 +768,6 @@ nsPluginTag::GetBlocklistState(uint32_t *aResult)
mCachedBlocklistState = (uint16_t) *aResult; mCachedBlocklistState = (uint16_t) *aResult;
mCachedBlocklistStateValid = true; mCachedBlocklistStateValid = true;
return NS_OK; return NS_OK;
#endif // defined(MOZ_WIDGET_ANDROID)
} }
void void

View file

@ -206,16 +206,6 @@ bool nsPluginsDir::IsPluginFile(nsIFile* file)
if (NS_FAILED(file->GetNativeLeafName(filename))) if (NS_FAILED(file->GetNativeLeafName(filename)))
return false; return false;
#ifdef ANDROID
// It appears that if you load
// 'libstagefright_honeycomb.so' on froyo, or
// 'libstagefright_froyo.so' on honeycomb, we will abort.
// Since these are just helper libs, we can ignore.
const char *cFile = filename.get();
if (strstr(cFile, "libstagefright") != nullptr)
return false;
#endif
NS_NAMED_LITERAL_CSTRING(dllSuffix, LOCAL_PLUGIN_DLL_SUFFIX); NS_NAMED_LITERAL_CSTRING(dllSuffix, LOCAL_PLUGIN_DLL_SUFFIX);
if (filename.Length() > dllSuffix.Length() && if (filename.Length() > dllSuffix.Length() &&
StringEndsWith(filename, dllSuffix)) StringEndsWith(filename, dllSuffix))

View file

@ -1,55 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This is a NPEventX11.h derived stub for Android
// Plugins aren't actually supported yet
#ifndef mozilla_dom_plugins_NPEventAndroid_h
#define mozilla_dom_plugins_NPEventAndroid_h
#include "npapi.h"
namespace mozilla {
namespace plugins {
struct NPRemoteEvent {
NPEvent event;
};
}
}
namespace IPC {
template <>
struct ParamTraits<mozilla::plugins::NPRemoteEvent>
{
typedef mozilla::plugins::NPRemoteEvent paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
aMsg->WriteBytes(&aParam, sizeof(paramType));
}
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
{
return aMsg->ReadBytesInto(aIter, aResult, sizeof(paramType));
}
static void Log(const paramType& aParam, std::wstring* aLog)
{
// TODO
aLog->append(L"(AndroidEvent)");
}
};
} // namespace IPC
#endif // mozilla_dom_plugins_NPEventAndroid_h

View file

@ -1427,8 +1427,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
if (mPluginIface->setwindow) if (mPluginIface->setwindow)
(void) mPluginIface->setwindow(&mData, &mWindow); (void) mPluginIface->setwindow(&mData, &mWindow);
#elif defined(ANDROID)
// TODO: Need Android impl
#elif defined(MOZ_WIDGET_UIKIT) #elif defined(MOZ_WIDGET_UIKIT)
// Don't care // Don't care
#else #else

View file

@ -265,9 +265,6 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(NativeWindowHandle*
XID id; XID id;
#elif defined(XP_DARWIN) #elif defined(XP_DARWIN)
intptr_t id; intptr_t id;
#elif defined(ANDROID)
// TODO: Need Android impl
int id;
#else #else
#warning Implement me #warning Implement me
#endif #endif

View file

@ -111,7 +111,7 @@ struct NPAudioDeviceChangeDetailsIPC
typedef HWND NativeWindowHandle; typedef HWND NativeWindowHandle;
#elif defined(MOZ_X11) #elif defined(MOZ_X11)
typedef XID NativeWindowHandle; typedef XID NativeWindowHandle;
#elif defined(XP_DARWIN) || defined(ANDROID) #elif defined(XP_DARWIN)
typedef intptr_t NativeWindowHandle; // never actually used, will always be 0 typedef intptr_t NativeWindowHandle; // never actually used, will always be 0
#else #else
#error Need NativeWindowHandle for this platform #error Need NativeWindowHandle for this platform
@ -736,8 +736,6 @@ struct ParamTraits<mozilla::plugins::NPAudioDeviceChangeDetailsIPC>
# include "mozilla/plugins/NPEventOSX.h" # include "mozilla/plugins/NPEventOSX.h"
#elif defined(XP_WIN) #elif defined(XP_WIN)
# include "mozilla/plugins/NPEventWindows.h" # include "mozilla/plugins/NPEventWindows.h"
#elif defined(ANDROID)
# include "mozilla/plugins/NPEventAndroid.h"
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
# include "mozilla/plugins/NPEventUnix.h" # include "mozilla/plugins/NPEventUnix.h"
#else #else

View file

@ -17,7 +17,6 @@ EXPORTS.mozilla.plugins += [
'BrowserStreamParent.h', 'BrowserStreamParent.h',
'ChildAsyncCall.h', 'ChildAsyncCall.h',
'ChildTimer.h', 'ChildTimer.h',
'NPEventAndroid.h',
'NPEventOSX.h', 'NPEventOSX.h',
'NPEventUnix.h', 'NPEventUnix.h',
'NPEventWindows.h', 'NPEventWindows.h',

View file

@ -1048,22 +1048,11 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global)
} }
#endif // defined(XP_MACOSX) #endif // defined(XP_MACOSX)
// sqlite3 is linked from different places depending on the platform // sqlite3 is always a shared lib
nsAutoString libsqlite3; nsAutoString libsqlite3;
#if defined(ANDROID)
// On Android, we use the system's libsqlite3
libsqlite3.AppendLiteral(DLL_PREFIX); libsqlite3.AppendLiteral(DLL_PREFIX);
libsqlite3.AppendLiteral("sqlite3"); libsqlite3.AppendLiteral("mozsqlite3");
libsqlite3.AppendLiteral(DLL_SUFFIX); libsqlite3.AppendLiteral(DLL_SUFFIX);
#elif defined(XP_WIN)
// On Windows, for some reason, this is part of nss3.dll
libsqlite3.AppendLiteral(DLL_PREFIX);
libsqlite3.AppendLiteral("nss3");
libsqlite3.AppendLiteral(DLL_SUFFIX);
#else
// On other platforms, we link sqlite3 into libxul
libsqlite3 = libxul;
#endif // defined(ANDROID) || defined(XP_WIN)
if (!SetStringProperty(cx, objPath, "libsqlite3", libsqlite3)) { if (!SetStringProperty(cx, objPath, "libsqlite3", libsqlite3)) {
return false; return false;

View file

@ -55,12 +55,14 @@ partial interface Performance {
attribute EventHandler onresourcetimingbufferfull; attribute EventHandler onresourcetimingbufferfull;
}; };
#ifdef MOZ_DEVTOOLS_SERVER
// GC microbenchmarks, pref-guarded, not for general use (bug 1125412) // GC microbenchmarks, pref-guarded, not for general use (bug 1125412)
[Exposed=Window] [Exposed=Window]
partial interface Performance { partial interface Performance {
[Pref="dom.enable_memory_stats"] [Pref="dom.enable_memory_stats"]
readonly attribute object mozMemory; readonly attribute object mozMemory;
}; };
#endif
// http://www.w3.org/TR/user-timing/ // http://www.w3.org/TR/user-timing/
[Exposed=(Window,Worker)] [Exposed=(Window,Worker)]

View file

@ -12,6 +12,7 @@ PREPROCESSED_WEBIDL_FILES = [
'HTMLMediaElement.webidl', 'HTMLMediaElement.webidl',
'Navigator.webidl', 'Navigator.webidl',
'Node.webidl', 'Node.webidl',
'Performance.webidl',
'Window.webidl', 'Window.webidl',
] ]
@ -329,7 +330,6 @@ WEBIDL_FILES = [
'PaintRequestList.webidl', 'PaintRequestList.webidl',
'PannerNode.webidl', 'PannerNode.webidl',
'ParentNode.webidl', 'ParentNode.webidl',
'Performance.webidl',
'PerformanceEntry.webidl', 'PerformanceEntry.webidl',
'PerformanceMark.webidl', 'PerformanceMark.webidl',
'PerformanceMeasure.webidl', 'PerformanceMeasure.webidl',

View file

@ -392,6 +392,7 @@ IsIncrementalBarrierNeededOnTenuredGCThing(JS::shadow::Runtime* rt, const JS::GC
return JS::shadow::Zone::asShadowZone(zone)->needsIncrementalBarrier(); return JS::shadow::Zone::asShadowZone(zone)->needsIncrementalBarrier();
} }
#ifdef MOZ_DEVTOOLS_SERVER
/** /**
* Create an object providing access to the garbage collector's internal notion * Create an object providing access to the garbage collector's internal notion
* of the current state of memory (both GC heap memory and GCthing-controlled * of the current state of memory (both GC heap memory and GCthing-controlled
@ -399,6 +400,7 @@ IsIncrementalBarrierNeededOnTenuredGCThing(JS::shadow::Runtime* rt, const JS::GC
*/ */
extern JS_PUBLIC_API(JSObject*) extern JS_PUBLIC_API(JSObject*)
NewMemoryInfoObject(JSContext* cx); NewMemoryInfoObject(JSContext* cx);
#endif
} /* namespace gc */ } /* namespace gc */
} /* namespace js */ } /* namespace js */

View file

@ -741,7 +741,9 @@ class GCRuntime
void removeBlackRootsTracer(JSTraceDataOp traceOp, void* data); void removeBlackRootsTracer(JSTraceDataOp traceOp, void* data);
void setMaxMallocBytes(size_t value); void setMaxMallocBytes(size_t value);
#ifdef MOZ_DEVTOOLS_SERVER
int32_t getMallocBytes() const { return mallocBytesUntilGC; } int32_t getMallocBytes() const { return mallocBytesUntilGC; }
#endif
void resetMallocBytes(); void resetMallocBytes();
bool isTooMuchMalloc() const { return mallocBytesUntilGC <= 0; } bool isTooMuchMalloc() const { return mallocBytesUntilGC <= 0; }
void updateMallocCounter(JS::Zone* zone, size_t nbytes); void updateMallocCounter(JS::Zone* zone, size_t nbytes);

View file

@ -505,7 +505,10 @@ js::Nursery::collect(JSRuntime* rt, JS::gcreason::Reason reason)
if (!isEnabled()) if (!isEnabled())
return; return;
#ifdef MOZ_DEVTOOLS_SERVER
// No need to obsessively track this without devtools
rt->gc.incMinorGcNumber(); rt->gc.incMinorGcNumber();
#endif
rt->gc.stats.beginNurseryCollection(reason); rt->gc.stats.beginNurseryCollection(reason);
TraceMinorGCStart(); TraceMinorGCStart();

View file

@ -6778,6 +6778,7 @@ js::gc::NextCellUniqueId(JSRuntime* rt)
namespace js { namespace js {
namespace gc { namespace gc {
#ifdef MOZ_DEVTOOLS_SERVER
namespace MemInfo { namespace MemInfo {
static bool static bool
@ -6993,6 +6994,7 @@ NewMemoryInfoObject(JSContext* cx)
return obj; return obj;
} }
#endif // MOZ_DEVTOOLS_SERVER
const char* const char*
StateName(State state) StateName(State state)

View file

@ -1357,8 +1357,10 @@ class ZoneList
ZoneList& operator=(const ZoneList& other) = delete; ZoneList& operator=(const ZoneList& other) = delete;
}; };
#ifdef MOZ_DEVTOOLS_SERVER
JSObject* JSObject*
NewMemoryStatisticsObject(JSContext* cx); NewMemoryStatisticsObject(JSContext* cx);
#endif
struct MOZ_RAII AutoAssertNoNurseryAlloc struct MOZ_RAII AutoAssertNoNurseryAlloc
{ {

View file

@ -7090,6 +7090,7 @@ NewGlobalObject(JSContext* cx, JS::CompartmentOptions& options,
if (!DefineOS(cx, glob, fuzzingSafe, &gOutFile, &gErrFile)) if (!DefineOS(cx, glob, fuzzingSafe, &gOutFile, &gErrFile))
return nullptr; return nullptr;
#ifdef MOZ_DEVTOOLS_SERVER
RootedObject performanceObj(cx, JS_NewObject(cx, nullptr)); RootedObject performanceObj(cx, JS_NewObject(cx, nullptr));
if (!performanceObj) if (!performanceObj)
return nullptr; return nullptr;
@ -7105,6 +7106,7 @@ NewGlobalObject(JSContext* cx, JS::CompartmentOptions& options,
return nullptr; return nullptr;
if (!JS_DefineProperty(cx, mozMemoryObj, "gc", gcObj, JSPROP_ENUMERATE)) if (!JS_DefineProperty(cx, mozMemoryObj, "gc", gcObj, JSPROP_ENUMERATE))
return nullptr; return nullptr;
#endif
/* Initialize FakeDOMObject. */ /* Initialize FakeDOMObject. */
static const js::DOMCallbacks DOMcallbacks = { static const js::DOMCallbacks DOMcallbacks = {

View file

@ -69,6 +69,9 @@ if not CONFIG['MOZ_DISABLE_PLATFORM']:
if CONFIG['COMPILE_ENVIRONMENT']: if CONFIG['COMPILE_ENVIRONMENT']:
if not CONFIG['JS_STANDALONE']: if not CONFIG['JS_STANDALONE']:
# Hopefully build sqlite before nss
DIRS += ['db/sqlite3/src']
DIRS += [ DIRS += [
'config/external', 'config/external',
'config/external/nss', 'config/external/nss',

View file

@ -590,42 +590,6 @@ function sortedArrayFromObject(obj) {
return tuples; return tuples;
} }
function copyRawDataToClipboard(button) {
if (button)
button.disabled = true;
try {
Troubleshoot.snapshot(function (snapshot) {
if (button)
button.disabled = false;
let str = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
str.data = JSON.stringify(snapshot, undefined, 2);
let transferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
transferable.init(getLoadContext());
transferable.addDataFlavor("text/unicode");
transferable.setTransferData("text/unicode", str, str.data.length * 2);
Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard).
setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
#ifdef MOZ_WIDGET_ANDROID
// Present a toast notification.
let message = {
type: "Toast:Show",
message: stringBundle().GetStringFromName("rawDataCopied"),
duration: "short"
};
Services.androidBridge.handleGeckoMessage(message);
#endif
});
}
catch (err) {
if (button)
button.disabled = false;
throw err;
}
}
function getLoadContext() { function getLoadContext() {
return window.QueryInterface(Ci.nsIInterfaceRequestor) return window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
@ -938,9 +902,6 @@ function setupEventListeners() {
$("reset-box-button").addEventListener("click", function(event) { $("reset-box-button").addEventListener("click", function(event) {
ResetProfile.openConfirmationDialog(window); ResetProfile.openConfirmationDialog(window);
}); });
$("copy-raw-data-to-clipboard").addEventListener("click", function(event) {
copyRawDataToClipboard(this);
});
$("copy-to-clipboard").addEventListener("click", function(event) { $("copy-to-clipboard").addEventListener("click", function(event) {
copyContentsToClipboard(); copyContentsToClipboard();
}); });

View file

@ -61,9 +61,6 @@
</div> </div>
<div> <div>
<button id="copy-raw-data-to-clipboard">
&aboutSupport.copyRawDataToClipboard.label;
</button>
<button id="copy-to-clipboard"> <button id="copy-to-clipboard">
&aboutSupport.copyTextToClipboard.label; &aboutSupport.copyTextToClipboard.label;
</button> </button>

View file

@ -106,7 +106,6 @@ variant of aboutSupport.showDir.label. -->
<!ENTITY aboutSupport.updateHistoryTitle "Update History"> <!ENTITY aboutSupport.updateHistoryTitle "Update History">
<!ENTITY aboutSupport.copyTextToClipboard.label "Copy text to clipboard"> <!ENTITY aboutSupport.copyTextToClipboard.label "Copy text to clipboard">
<!ENTITY aboutSupport.copyRawDataToClipboard.label "Copy raw data to clipboard">
<!ENTITY aboutSupport.safeModeTitle "Try Safe Mode"> <!ENTITY aboutSupport.safeModeTitle "Try Safe Mode">
<!ENTITY aboutSupport.restartInSafeMode.label "Restart in Safe Mode…"> <!ENTITY aboutSupport.restartInSafeMode.label "Restart in Safe Mode…">

View file

@ -33,10 +33,6 @@ pendingReports=All Crash Reports (including #1 pending crash in the given time r
# "GPU Accelerated Windows: 0/2" # "GPU Accelerated Windows: 0/2"
acceleratedWindows = GPU Accelerated Windows acceleratedWindows = GPU Accelerated Windows
# LOCALIZATION NOTE (rawDataCopied) Text displayed in a mobile "Toast" to user when the
# raw data is successfully copied to the clipboard via button press.
rawDataCopied=Raw data copied to clipboard
# LOCALIZATION NOTE (textCopied) Text displayed in a mobile "Toast" to user when the # LOCALIZATION NOTE (textCopied) Text displayed in a mobile "Toast" to user when the
# text is successfully copied to the clipboard via button press. # text is successfully copied to the clipboard via button press.
textCopied=Text copied to clipboard textCopied=Text copied to clipboard

View file

@ -3,6 +3,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#filter substitution #filter substitution
#if !MOZ_PKG_SPECIAL
#define MOZ_PKG_SPECIAL false
#endif
this.EXPORTED_SYMBOLS = ["UpdateUtils"]; this.EXPORTED_SYMBOLS = ["UpdateUtils"];
@ -70,6 +73,7 @@ this.UpdateUtils = {
url = url.replace(/%VERSION%/g, Services.appinfo.version); url = url.replace(/%VERSION%/g, Services.appinfo.version);
url = url.replace(/%BUILD_ID%/g, Services.appinfo.appBuildID); url = url.replace(/%BUILD_ID%/g, Services.appinfo.appBuildID);
url = url.replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + this.ABI); url = url.replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + this.ABI);
url = url.replace(/%BUILD_SPECIAL%/g, "@MOZ_PKG_SPECIAL@");
url = url.replace(/%OS_VERSION%/g, this.OSVersion); url = url.replace(/%OS_VERSION%/g, this.OSVersion);
url = url.replace(/%WIDGET_TOOLKIT%/g, "@MOZ_WIDGET_TOOLKIT@"); url = url.replace(/%WIDGET_TOOLKIT%/g, "@MOZ_WIDGET_TOOLKIT@");
url = url.replace(/%CHANNEL%/g, this.UpdateChannel); url = url.replace(/%CHANNEL%/g, this.UpdateChannel);

View file

@ -139,6 +139,7 @@ for var in ('ANDROID_PACKAGE_NAME',
'MOZ_APP_VERSION_DISPLAY', 'MOZ_APP_VERSION_DISPLAY',
'MOZ_MACBUNDLE_NAME', 'MOZ_MACBUNDLE_NAME',
'MOZ_WIDGET_TOOLKIT', 'MOZ_WIDGET_TOOLKIT',
'MOZ_PKG_SPECIAL',
'DLL_PREFIX', 'DLL_PREFIX',
'DLL_SUFFIX', 'DLL_SUFFIX',
'DEBUG_JS_MODULES'): 'DEBUG_JS_MODULES'):

View file

@ -30,7 +30,6 @@ namespace widget {
class WinCompositorWidget; class WinCompositorWidget;
class X11CompositorWidget; class X11CompositorWidget;
class AndroidCompositorWidget;
class CompositorWidgetInitData; class CompositorWidgetInitData;
// Gecko widgets usually need to communicate with the CompositorWidget with // Gecko widgets usually need to communicate with the CompositorWidget with
@ -56,12 +55,9 @@ class CompositorWidgetChild;
class WidgetRenderingContext class WidgetRenderingContext
{ {
public: public:
#if defined(XP_MACOSX) #ifdef XP_MACOSX
WidgetRenderingContext() : mLayerManager(nullptr) {} WidgetRenderingContext() : mLayerManager(nullptr) {}
layers::LayerManagerComposite* mLayerManager; layers::LayerManagerComposite* mLayerManager;
#elif defined(MOZ_WIDGET_ANDROID)
WidgetRenderingContext() : mCompositor(nullptr) {}
layers::Compositor* mCompositor;
#endif #endif
}; };
@ -262,9 +258,6 @@ public:
virtual X11CompositorWidget* AsX11() { virtual X11CompositorWidget* AsX11() {
return nullptr; return nullptr;
} }
virtual AndroidCompositorWidget* AsAndroid() {
return nullptr;
}
/** /**
* Return the platform-specific delegate for the widget, if any. * Return the platform-specific delegate for the widget, if any.

View file

@ -379,9 +379,6 @@ NS_EVENT_MESSAGE(eDeviceMotion)
NS_EVENT_MESSAGE(eDeviceProximity) NS_EVENT_MESSAGE(eDeviceProximity)
NS_EVENT_MESSAGE(eUserProximity) NS_EVENT_MESSAGE(eUserProximity)
NS_EVENT_MESSAGE(eDeviceLight) NS_EVENT_MESSAGE(eDeviceLight)
#if defined(MOZ_WIDGET_ANDROID)
NS_EVENT_MESSAGE(eOrientationChange)
#endif
// WebVR events // WebVR events
NS_EVENT_MESSAGE(eVRDisplayConnect) NS_EVENT_MESSAGE(eVRDisplayConnect)

View file

@ -58,7 +58,6 @@ enum class OperatingSystem {
OSX10_10, OSX10_10,
OSX10_11, OSX10_11,
OSX10_12, OSX10_12,
Android,
Ios Ios
}; };
@ -283,12 +282,6 @@ ParseDriverVersion(const nsAString& aVersion, uint64_t *aNumericVersion)
*aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d); *aNumericVersion = GFX_DRIVER_VERSION(a, b, c, d);
MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions); MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions);
return true; return true;
#elif defined(ANDROID)
// Can't use aVersion.ToInteger() because that's not compiled into our code
// unless we have XPCOM_GLUE_AVOID_NSPR disabled.
*aNumericVersion = atoi(NS_LossyConvertUTF16toASCII(aVersion).get());
MOZ_ASSERT(*aNumericVersion != GfxDriverInfo::allDriverVersions);
return true;
#else #else
return false; return false;
#endif #endif

View file

@ -280,8 +280,6 @@ BlacklistOSToOperatingSystem(const nsAString& os)
return OperatingSystem::OSX10_11; return OperatingSystem::OSX10_11;
else if (os.EqualsLiteral("Darwin 16")) else if (os.EqualsLiteral("Darwin 16"))
return OperatingSystem::OSX10_12; return OperatingSystem::OSX10_12;
else if (os.EqualsLiteral("Android"))
return OperatingSystem::Android;
// For historical reasons, "All" in blocklist means "All Windows" // For historical reasons, "All" in blocklist means "All Windows"
else if (os.EqualsLiteral("All")) else if (os.EqualsLiteral("All"))
return OperatingSystem::Windows; return OperatingSystem::Windows;
@ -697,7 +695,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info,
} }
} }
#if defined(XP_WIN) || defined(ANDROID) #ifdef XP_WIN
uint64_t driverVersion; uint64_t driverVersion;
ParseDriverVersion(adapterDriverVersionString, &driverVersion); ParseDriverVersion(adapterDriverVersionString, &driverVersion);
#endif #endif
@ -736,7 +734,7 @@ GfxInfoBase::FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& info,
continue; continue;
} }
#if defined(XP_WIN) || defined(ANDROID) #ifdef XP_WIN
switch (info[i].mComparisonOp) { switch (info[i].mComparisonOp) {
case DRIVER_LESS_THAN: case DRIVER_LESS_THAN:
match = driverVersion < info[i].mDriverVersion; match = driverVersion < info[i].mDriverVersion;

View file

@ -5,10 +5,6 @@
#include "InProcessCompositorWidget.h" #include "InProcessCompositorWidget.h"
#include "nsBaseWidget.h" #include "nsBaseWidget.h"
#if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
#include "mozilla/widget/AndroidCompositorWidget.h"
#endif
namespace mozilla { namespace mozilla {
namespace widget { namespace widget {
@ -19,11 +15,7 @@ namespace widget {
CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget) CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
{ {
MOZ_ASSERT(aWidget); MOZ_ASSERT(aWidget);
#ifdef MOZ_WIDGET_ANDROID
return new AndroidCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
#else
return new InProcessCompositorWidget(static_cast<nsBaseWidget*>(aWidget)); return new InProcessCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
#endif
} }
#endif #endif

View file

@ -21,8 +21,6 @@
#define CODE_MAP_MAC(aCPPCodeName, aNativeKey) #define CODE_MAP_MAC(aCPPCodeName, aNativeKey)
// GTK and Qt on Linux // GTK and Qt on Linux
#define CODE_MAP_X11(aCPPCodeName, aNativeKey) #define CODE_MAP_X11(aCPPCodeName, aNativeKey)
// Android and Gonk
#define CODE_MAP_ANDROID(aCPPCodeName, aNativeKey)
#if defined(XP_WIN) #if defined(XP_WIN)
#undef CODE_MAP_WIN #undef CODE_MAP_WIN
@ -42,780 +40,613 @@
#define CODE_MAP_X11(aCPPCodeName, aNativeKey) \ #define CODE_MAP_X11(aCPPCodeName, aNativeKey) \
NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \ NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \
CODE_NAME_INDEX_##aCPPCodeName) CODE_NAME_INDEX_##aCPPCodeName)
#elif defined(ANDROID)
#undef CODE_MAP_ANDROID
// aNativeKey is scan code
#define CODE_MAP_ANDROID(aCPPCodeName, aNativeKey) \
NS_NATIVE_KEY_TO_DOM_CODE_NAME_INDEX(aNativeKey, \
CODE_NAME_INDEX_##aCPPCodeName)
#endif #endif
// Writing system keys // Writing system keys
CODE_MAP_WIN(Backquote, 0x0029) CODE_MAP_WIN(Backquote, 0x0029)
CODE_MAP_MAC(Backquote, kVK_ANSI_Grave) CODE_MAP_MAC(Backquote, kVK_ANSI_Grave)
CODE_MAP_X11(Backquote, 0x0031) CODE_MAP_X11(Backquote, 0x0031)
CODE_MAP_ANDROID(Backquote, 0x0029)
CODE_MAP_WIN(Backslash, 0x002B) CODE_MAP_WIN(Backslash, 0x002B)
CODE_MAP_MAC(Backslash, kVK_ANSI_Backslash) CODE_MAP_MAC(Backslash, kVK_ANSI_Backslash)
CODE_MAP_X11(Backslash, 0x0033) CODE_MAP_X11(Backslash, 0x0033)
CODE_MAP_ANDROID(Backslash, 0x002B)
CODE_MAP_WIN(Backspace, 0x000E) CODE_MAP_WIN(Backspace, 0x000E)
CODE_MAP_MAC(Backspace, kVK_Delete) CODE_MAP_MAC(Backspace, kVK_Delete)
CODE_MAP_X11(Backspace, 0x0016) CODE_MAP_X11(Backspace, 0x0016)
CODE_MAP_ANDROID(Backspace, 0x000E)
CODE_MAP_WIN(BracketLeft, 0x001A) CODE_MAP_WIN(BracketLeft, 0x001A)
CODE_MAP_MAC(BracketLeft, kVK_ANSI_LeftBracket) CODE_MAP_MAC(BracketLeft, kVK_ANSI_LeftBracket)
CODE_MAP_X11(BracketLeft, 0x0022) CODE_MAP_X11(BracketLeft, 0x0022)
CODE_MAP_ANDROID(BracketLeft, 0x001A)
CODE_MAP_WIN(BracketRight, 0x001B) CODE_MAP_WIN(BracketRight, 0x001B)
CODE_MAP_MAC(BracketRight, kVK_ANSI_RightBracket) CODE_MAP_MAC(BracketRight, kVK_ANSI_RightBracket)
CODE_MAP_X11(BracketRight, 0x0023) CODE_MAP_X11(BracketRight, 0x0023)
CODE_MAP_ANDROID(BracketRight, 0x001B)
CODE_MAP_WIN(Comma, 0x0033) CODE_MAP_WIN(Comma, 0x0033)
CODE_MAP_MAC(Comma, kVK_ANSI_Comma) CODE_MAP_MAC(Comma, kVK_ANSI_Comma)
CODE_MAP_X11(Comma, 0x003B) CODE_MAP_X11(Comma, 0x003B)
CODE_MAP_ANDROID(Comma, 0x00033)
CODE_MAP_WIN(Digit0, 0x000B) CODE_MAP_WIN(Digit0, 0x000B)
CODE_MAP_MAC(Digit0, kVK_ANSI_0) CODE_MAP_MAC(Digit0, kVK_ANSI_0)
CODE_MAP_X11(Digit0, 0x0013) CODE_MAP_X11(Digit0, 0x0013)
CODE_MAP_ANDROID(Digit0, 0x000B)
CODE_MAP_WIN(Digit1, 0x0002) CODE_MAP_WIN(Digit1, 0x0002)
CODE_MAP_MAC(Digit1, kVK_ANSI_1) CODE_MAP_MAC(Digit1, kVK_ANSI_1)
CODE_MAP_X11(Digit1, 0x000A) CODE_MAP_X11(Digit1, 0x000A)
CODE_MAP_ANDROID(Digit1, 0x0002)
CODE_MAP_WIN(Digit2, 0x0003) CODE_MAP_WIN(Digit2, 0x0003)
CODE_MAP_MAC(Digit2, kVK_ANSI_2) CODE_MAP_MAC(Digit2, kVK_ANSI_2)
CODE_MAP_X11(Digit2, 0x000B) CODE_MAP_X11(Digit2, 0x000B)
CODE_MAP_ANDROID(Digit2, 0x0003)
CODE_MAP_WIN(Digit3, 0x0004) CODE_MAP_WIN(Digit3, 0x0004)
CODE_MAP_MAC(Digit3, kVK_ANSI_3) CODE_MAP_MAC(Digit3, kVK_ANSI_3)
CODE_MAP_X11(Digit3, 0x000C) CODE_MAP_X11(Digit3, 0x000C)
CODE_MAP_ANDROID(Digit3, 0x0004)
CODE_MAP_WIN(Digit4, 0x0005) CODE_MAP_WIN(Digit4, 0x0005)
CODE_MAP_MAC(Digit4, kVK_ANSI_4) CODE_MAP_MAC(Digit4, kVK_ANSI_4)
CODE_MAP_X11(Digit4, 0x000D) CODE_MAP_X11(Digit4, 0x000D)
CODE_MAP_ANDROID(Digit4, 0x0005)
CODE_MAP_WIN(Digit5, 0x0006) CODE_MAP_WIN(Digit5, 0x0006)
CODE_MAP_MAC(Digit5, kVK_ANSI_5) CODE_MAP_MAC(Digit5, kVK_ANSI_5)
CODE_MAP_X11(Digit5, 0x000E) CODE_MAP_X11(Digit5, 0x000E)
CODE_MAP_ANDROID(Digit5, 0x0006)
CODE_MAP_WIN(Digit6, 0x0007) CODE_MAP_WIN(Digit6, 0x0007)
CODE_MAP_MAC(Digit6, kVK_ANSI_6) CODE_MAP_MAC(Digit6, kVK_ANSI_6)
CODE_MAP_X11(Digit6, 0x000F) CODE_MAP_X11(Digit6, 0x000F)
CODE_MAP_ANDROID(Digit6, 0x0007)
CODE_MAP_WIN(Digit7, 0x0008) CODE_MAP_WIN(Digit7, 0x0008)
CODE_MAP_MAC(Digit7, kVK_ANSI_7) CODE_MAP_MAC(Digit7, kVK_ANSI_7)
CODE_MAP_X11(Digit7, 0x0010) CODE_MAP_X11(Digit7, 0x0010)
CODE_MAP_ANDROID(Digit7, 0x0008)
CODE_MAP_WIN(Digit8, 0x0009) CODE_MAP_WIN(Digit8, 0x0009)
CODE_MAP_MAC(Digit8, kVK_ANSI_8) CODE_MAP_MAC(Digit8, kVK_ANSI_8)
CODE_MAP_X11(Digit8, 0x0011) CODE_MAP_X11(Digit8, 0x0011)
CODE_MAP_ANDROID(Digit8, 0x0009)
CODE_MAP_WIN(Digit9, 0x000A) CODE_MAP_WIN(Digit9, 0x000A)
CODE_MAP_MAC(Digit9, kVK_ANSI_9) CODE_MAP_MAC(Digit9, kVK_ANSI_9)
CODE_MAP_X11(Digit9, 0x0012) CODE_MAP_X11(Digit9, 0x0012)
CODE_MAP_ANDROID(Digit9, 0x000A)
CODE_MAP_WIN(Equal, 0x000D) CODE_MAP_WIN(Equal, 0x000D)
CODE_MAP_MAC(Equal, kVK_ANSI_Equal) CODE_MAP_MAC(Equal, kVK_ANSI_Equal)
CODE_MAP_X11(Equal, 0x0015) CODE_MAP_X11(Equal, 0x0015)
CODE_MAP_ANDROID(Equal, 0x000D)
CODE_MAP_WIN(IntlBackslash, 0x0056) CODE_MAP_WIN(IntlBackslash, 0x0056)
CODE_MAP_MAC(IntlBackslash, kVK_ISO_Section) CODE_MAP_MAC(IntlBackslash, kVK_ISO_Section)
CODE_MAP_X11(IntlBackslash, 0x005E) CODE_MAP_X11(IntlBackslash, 0x005E)
CODE_MAP_ANDROID(IntlBackslash, 0x0056)
// Win: IntlHash's scan code is shared with "Backslash" key. // Win: IntlHash's scan code is shared with "Backslash" key.
// Mac: IntlHash's virtual key code is shared with "Backslash" key. // Mac: IntlHash's virtual key code is shared with "Backslash" key.
// X11: IntlHash's scan code is shared with "Backslash" key. // X11: IntlHash's scan code is shared with "Backslash" key.
// Android: IntlHash's scan code is shared with "Backslash" key.
CODE_MAP_WIN(IntlRo, 0x0073) CODE_MAP_WIN(IntlRo, 0x0073)
CODE_MAP_MAC(IntlRo, kVK_JIS_Underscore) CODE_MAP_MAC(IntlRo, kVK_JIS_Underscore)
CODE_MAP_X11(IntlRo, 0x0061) CODE_MAP_X11(IntlRo, 0x0061)
CODE_MAP_ANDROID(IntlRo, 0x0059)
CODE_MAP_WIN(IntlYen, 0x007D) CODE_MAP_WIN(IntlYen, 0x007D)
CODE_MAP_MAC(IntlYen, kVK_JIS_Yen) CODE_MAP_MAC(IntlYen, kVK_JIS_Yen)
CODE_MAP_X11(IntlYen, 0x0084) CODE_MAP_X11(IntlYen, 0x0084)
CODE_MAP_ANDROID(IntlYen, 0x007C)
CODE_MAP_WIN(KeyA, 0x001E) CODE_MAP_WIN(KeyA, 0x001E)
CODE_MAP_MAC(KeyA, kVK_ANSI_A) CODE_MAP_MAC(KeyA, kVK_ANSI_A)
CODE_MAP_X11(KeyA, 0x0026) CODE_MAP_X11(KeyA, 0x0026)
CODE_MAP_ANDROID(KeyA, 0x001E)
CODE_MAP_WIN(KeyB, 0x0030) CODE_MAP_WIN(KeyB, 0x0030)
CODE_MAP_MAC(KeyB, kVK_ANSI_B) CODE_MAP_MAC(KeyB, kVK_ANSI_B)
CODE_MAP_X11(KeyB, 0x0038) CODE_MAP_X11(KeyB, 0x0038)
CODE_MAP_ANDROID(KeyB, 0x0030)
CODE_MAP_WIN(KeyC, 0x002E) CODE_MAP_WIN(KeyC, 0x002E)
CODE_MAP_MAC(KeyC, kVK_ANSI_C) CODE_MAP_MAC(KeyC, kVK_ANSI_C)
CODE_MAP_X11(KeyC, 0x0036) CODE_MAP_X11(KeyC, 0x0036)
CODE_MAP_ANDROID(KeyC, 0x002E)
CODE_MAP_WIN(KeyD, 0x0020) CODE_MAP_WIN(KeyD, 0x0020)
CODE_MAP_MAC(KeyD, kVK_ANSI_D) CODE_MAP_MAC(KeyD, kVK_ANSI_D)
CODE_MAP_X11(KeyD, 0x0028) CODE_MAP_X11(KeyD, 0x0028)
CODE_MAP_ANDROID(KeyD, 0x0020)
CODE_MAP_WIN(KeyE, 0x0012) CODE_MAP_WIN(KeyE, 0x0012)
CODE_MAP_MAC(KeyE, kVK_ANSI_E) CODE_MAP_MAC(KeyE, kVK_ANSI_E)
CODE_MAP_X11(KeyE, 0x001A) CODE_MAP_X11(KeyE, 0x001A)
CODE_MAP_ANDROID(KeyE, 0x0012)
CODE_MAP_WIN(KeyF, 0x0021) CODE_MAP_WIN(KeyF, 0x0021)
CODE_MAP_MAC(KeyF, kVK_ANSI_F) CODE_MAP_MAC(KeyF, kVK_ANSI_F)
CODE_MAP_X11(KeyF, 0x0029) CODE_MAP_X11(KeyF, 0x0029)
CODE_MAP_ANDROID(KeyF, 0x0021)
CODE_MAP_WIN(KeyG, 0x0022) CODE_MAP_WIN(KeyG, 0x0022)
CODE_MAP_MAC(KeyG, kVK_ANSI_G) CODE_MAP_MAC(KeyG, kVK_ANSI_G)
CODE_MAP_X11(KeyG, 0x002A) CODE_MAP_X11(KeyG, 0x002A)
CODE_MAP_ANDROID(KeyG, 0x0022)
CODE_MAP_WIN(KeyH, 0x0023) CODE_MAP_WIN(KeyH, 0x0023)
CODE_MAP_MAC(KeyH, kVK_ANSI_H) CODE_MAP_MAC(KeyH, kVK_ANSI_H)
CODE_MAP_X11(KeyH, 0x002B) CODE_MAP_X11(KeyH, 0x002B)
CODE_MAP_ANDROID(KeyH, 0x0023)
CODE_MAP_WIN(KeyI, 0x0017) CODE_MAP_WIN(KeyI, 0x0017)
CODE_MAP_MAC(KeyI, kVK_ANSI_I) CODE_MAP_MAC(KeyI, kVK_ANSI_I)
CODE_MAP_X11(KeyI, 0x001F) CODE_MAP_X11(KeyI, 0x001F)
CODE_MAP_ANDROID(KeyI, 0x0017)
CODE_MAP_WIN(KeyJ, 0x0024) CODE_MAP_WIN(KeyJ, 0x0024)
CODE_MAP_MAC(KeyJ, kVK_ANSI_J) CODE_MAP_MAC(KeyJ, kVK_ANSI_J)
CODE_MAP_X11(KeyJ, 0x002C) CODE_MAP_X11(KeyJ, 0x002C)
CODE_MAP_ANDROID(KeyJ, 0x0024)
CODE_MAP_WIN(KeyK, 0x0025) CODE_MAP_WIN(KeyK, 0x0025)
CODE_MAP_MAC(KeyK, kVK_ANSI_K) CODE_MAP_MAC(KeyK, kVK_ANSI_K)
CODE_MAP_X11(KeyK, 0x002D) CODE_MAP_X11(KeyK, 0x002D)
CODE_MAP_ANDROID(KeyK, 0x0025)
CODE_MAP_WIN(KeyL, 0x0026) CODE_MAP_WIN(KeyL, 0x0026)
CODE_MAP_MAC(KeyL, kVK_ANSI_L) CODE_MAP_MAC(KeyL, kVK_ANSI_L)
CODE_MAP_X11(KeyL, 0x002E) CODE_MAP_X11(KeyL, 0x002E)
CODE_MAP_ANDROID(KeyL, 0x0026)
CODE_MAP_WIN(KeyM, 0x0032) CODE_MAP_WIN(KeyM, 0x0032)
CODE_MAP_MAC(KeyM, kVK_ANSI_M) CODE_MAP_MAC(KeyM, kVK_ANSI_M)
CODE_MAP_X11(KeyM, 0x003A) CODE_MAP_X11(KeyM, 0x003A)
CODE_MAP_ANDROID(KeyM, 0x0032)
CODE_MAP_WIN(KeyN, 0x0031) CODE_MAP_WIN(KeyN, 0x0031)
CODE_MAP_MAC(KeyN, kVK_ANSI_N) CODE_MAP_MAC(KeyN, kVK_ANSI_N)
CODE_MAP_X11(KeyN, 0x0039) CODE_MAP_X11(KeyN, 0x0039)
CODE_MAP_ANDROID(KeyN, 0x0031)
CODE_MAP_WIN(KeyO, 0x0018) CODE_MAP_WIN(KeyO, 0x0018)
CODE_MAP_MAC(KeyO, kVK_ANSI_O) CODE_MAP_MAC(KeyO, kVK_ANSI_O)
CODE_MAP_X11(KeyO, 0x0020) CODE_MAP_X11(KeyO, 0x0020)
CODE_MAP_ANDROID(KeyO, 0x0018)
CODE_MAP_WIN(KeyP, 0x0019) CODE_MAP_WIN(KeyP, 0x0019)
CODE_MAP_MAC(KeyP, kVK_ANSI_P) CODE_MAP_MAC(KeyP, kVK_ANSI_P)
CODE_MAP_X11(KeyP, 0x0021) CODE_MAP_X11(KeyP, 0x0021)
CODE_MAP_ANDROID(KeyP, 0x0019)
CODE_MAP_WIN(KeyQ, 0x0010) CODE_MAP_WIN(KeyQ, 0x0010)
CODE_MAP_MAC(KeyQ, kVK_ANSI_Q) CODE_MAP_MAC(KeyQ, kVK_ANSI_Q)
CODE_MAP_X11(KeyQ, 0x0018) CODE_MAP_X11(KeyQ, 0x0018)
CODE_MAP_ANDROID(KeyQ, 0x0010)
CODE_MAP_WIN(KeyR, 0x0013) CODE_MAP_WIN(KeyR, 0x0013)
CODE_MAP_MAC(KeyR, kVK_ANSI_R) CODE_MAP_MAC(KeyR, kVK_ANSI_R)
CODE_MAP_X11(KeyR, 0x001B) CODE_MAP_X11(KeyR, 0x001B)
CODE_MAP_ANDROID(KeyR, 0x0013)
CODE_MAP_WIN(KeyS, 0x001F) CODE_MAP_WIN(KeyS, 0x001F)
CODE_MAP_MAC(KeyS, kVK_ANSI_S) CODE_MAP_MAC(KeyS, kVK_ANSI_S)
CODE_MAP_X11(KeyS, 0x0027) CODE_MAP_X11(KeyS, 0x0027)
CODE_MAP_ANDROID(KeyS, 0x001F)
CODE_MAP_WIN(KeyT, 0x0014) CODE_MAP_WIN(KeyT, 0x0014)
CODE_MAP_MAC(KeyT, kVK_ANSI_T) CODE_MAP_MAC(KeyT, kVK_ANSI_T)
CODE_MAP_X11(KeyT, 0x001C) CODE_MAP_X11(KeyT, 0x001C)
CODE_MAP_ANDROID(KeyT, 0x0014)
CODE_MAP_WIN(KeyU, 0x0016) CODE_MAP_WIN(KeyU, 0x0016)
CODE_MAP_MAC(KeyU, kVK_ANSI_U) CODE_MAP_MAC(KeyU, kVK_ANSI_U)
CODE_MAP_X11(KeyU, 0x001E) CODE_MAP_X11(KeyU, 0x001E)
CODE_MAP_ANDROID(KeyU, 0x0016)
CODE_MAP_WIN(KeyV, 0x002F) CODE_MAP_WIN(KeyV, 0x002F)
CODE_MAP_MAC(KeyV, kVK_ANSI_V) CODE_MAP_MAC(KeyV, kVK_ANSI_V)
CODE_MAP_X11(KeyV, 0x0037) CODE_MAP_X11(KeyV, 0x0037)
CODE_MAP_ANDROID(KeyV, 0x002F)
CODE_MAP_WIN(KeyW, 0x0011) CODE_MAP_WIN(KeyW, 0x0011)
CODE_MAP_MAC(KeyW, kVK_ANSI_W) CODE_MAP_MAC(KeyW, kVK_ANSI_W)
CODE_MAP_X11(KeyW, 0x0019) CODE_MAP_X11(KeyW, 0x0019)
CODE_MAP_ANDROID(KeyW, 0x0011)
CODE_MAP_WIN(KeyX, 0x002D) CODE_MAP_WIN(KeyX, 0x002D)
CODE_MAP_MAC(KeyX, kVK_ANSI_X) CODE_MAP_MAC(KeyX, kVK_ANSI_X)
CODE_MAP_X11(KeyX, 0x0035) CODE_MAP_X11(KeyX, 0x0035)
CODE_MAP_ANDROID(KeyX, 0x002D)
CODE_MAP_WIN(KeyY, 0x0015) CODE_MAP_WIN(KeyY, 0x0015)
CODE_MAP_MAC(KeyY, kVK_ANSI_Y) CODE_MAP_MAC(KeyY, kVK_ANSI_Y)
CODE_MAP_X11(KeyY, 0x001D) CODE_MAP_X11(KeyY, 0x001D)
CODE_MAP_ANDROID(KeyY, 0x0015)
CODE_MAP_WIN(KeyZ, 0x002C) CODE_MAP_WIN(KeyZ, 0x002C)
CODE_MAP_MAC(KeyZ, kVK_ANSI_Z) CODE_MAP_MAC(KeyZ, kVK_ANSI_Z)
CODE_MAP_X11(KeyZ, 0x0034) CODE_MAP_X11(KeyZ, 0x0034)
CODE_MAP_ANDROID(KeyZ, 0x002C)
CODE_MAP_WIN(Minus, 0x000C) CODE_MAP_WIN(Minus, 0x000C)
CODE_MAP_MAC(Minus, kVK_ANSI_Minus) CODE_MAP_MAC(Minus, kVK_ANSI_Minus)
CODE_MAP_X11(Minus, 0x0014) CODE_MAP_X11(Minus, 0x0014)
CODE_MAP_ANDROID(Minus, 0x000C)
CODE_MAP_WIN(Period, 0x0034) CODE_MAP_WIN(Period, 0x0034)
CODE_MAP_MAC(Period, kVK_ANSI_Period) CODE_MAP_MAC(Period, kVK_ANSI_Period)
CODE_MAP_X11(Period, 0x003C) CODE_MAP_X11(Period, 0x003C)
CODE_MAP_ANDROID(Period, 0x0034)
CODE_MAP_WIN(Quote, 0x0028) CODE_MAP_WIN(Quote, 0x0028)
CODE_MAP_MAC(Quote, kVK_ANSI_Quote) CODE_MAP_MAC(Quote, kVK_ANSI_Quote)
CODE_MAP_X11(Quote, 0x0030) CODE_MAP_X11(Quote, 0x0030)
CODE_MAP_ANDROID(Quote, 0x0028)
CODE_MAP_WIN(Semicolon, 0x0027) CODE_MAP_WIN(Semicolon, 0x0027)
CODE_MAP_MAC(Semicolon, kVK_ANSI_Semicolon) CODE_MAP_MAC(Semicolon, kVK_ANSI_Semicolon)
CODE_MAP_X11(Semicolon, 0x002F) CODE_MAP_X11(Semicolon, 0x002F)
CODE_MAP_ANDROID(Semicolon, 0x0027)
CODE_MAP_WIN(Slash, 0x0035) CODE_MAP_WIN(Slash, 0x0035)
CODE_MAP_MAC(Slash, kVK_ANSI_Slash) CODE_MAP_MAC(Slash, kVK_ANSI_Slash)
CODE_MAP_X11(Slash, 0x003D) CODE_MAP_X11(Slash, 0x003D)
CODE_MAP_ANDROID(Slash, 0x0035)
// Functional keys // Functional keys
CODE_MAP_WIN(AltLeft, 0x0038) CODE_MAP_WIN(AltLeft, 0x0038)
CODE_MAP_MAC(AltLeft, kVK_Option) CODE_MAP_MAC(AltLeft, kVK_Option)
CODE_MAP_X11(AltLeft, 0x0040) CODE_MAP_X11(AltLeft, 0x0040)
CODE_MAP_ANDROID(AltLeft, 0x0038)
CODE_MAP_WIN(AltRight, 0xE038) CODE_MAP_WIN(AltRight, 0xE038)
CODE_MAP_MAC(AltRight, kVK_RightOption) CODE_MAP_MAC(AltRight, kVK_RightOption)
CODE_MAP_X11(AltRight, 0x006C) CODE_MAP_X11(AltRight, 0x006C)
CODE_MAP_ANDROID(AltRight, 0x0064)
CODE_MAP_WIN(CapsLock, 0x003A) CODE_MAP_WIN(CapsLock, 0x003A)
CODE_MAP_MAC(CapsLock, kVK_CapsLock) CODE_MAP_MAC(CapsLock, kVK_CapsLock)
CODE_MAP_X11(CapsLock, 0x0042) CODE_MAP_X11(CapsLock, 0x0042)
CODE_MAP_ANDROID(CapsLock, 0x003A)
CODE_MAP_WIN(ContextMenu, 0xE05D) CODE_MAP_WIN(ContextMenu, 0xE05D)
CODE_MAP_MAC(ContextMenu, kVK_PC_ContextMenu) CODE_MAP_MAC(ContextMenu, kVK_PC_ContextMenu)
CODE_MAP_X11(ContextMenu, 0x0087) CODE_MAP_X11(ContextMenu, 0x0087)
CODE_MAP_ANDROID(ContextMenu, 0x007F)
CODE_MAP_WIN(ControlLeft, 0x001D) CODE_MAP_WIN(ControlLeft, 0x001D)
CODE_MAP_MAC(ControlLeft, kVK_Control) CODE_MAP_MAC(ControlLeft, kVK_Control)
CODE_MAP_X11(ControlLeft, 0x0025) CODE_MAP_X11(ControlLeft, 0x0025)
CODE_MAP_ANDROID(ControlLeft, 0x001D)
CODE_MAP_WIN(ControlRight, 0xE01D) CODE_MAP_WIN(ControlRight, 0xE01D)
CODE_MAP_MAC(ControlRight, kVK_RightControl) CODE_MAP_MAC(ControlRight, kVK_RightControl)
CODE_MAP_X11(ControlRight, 0x0069) CODE_MAP_X11(ControlRight, 0x0069)
CODE_MAP_ANDROID(ControlRight, 0x0061)
CODE_MAP_WIN(Enter, 0x001C) CODE_MAP_WIN(Enter, 0x001C)
CODE_MAP_MAC(Enter, kVK_Return) CODE_MAP_MAC(Enter, kVK_Return)
CODE_MAP_X11(Enter, 0x0024) CODE_MAP_X11(Enter, 0x0024)
CODE_MAP_ANDROID(Enter, 0x001C)
CODE_MAP_WIN(OSLeft, 0xE05B) CODE_MAP_WIN(OSLeft, 0xE05B)
CODE_MAP_MAC(OSLeft, kVK_Command) CODE_MAP_MAC(OSLeft, kVK_Command)
CODE_MAP_X11(OSLeft, 0x0085) CODE_MAP_X11(OSLeft, 0x0085)
CODE_MAP_ANDROID(OSLeft, 0x007D)
CODE_MAP_WIN(OSRight, 0xE05C) CODE_MAP_WIN(OSRight, 0xE05C)
CODE_MAP_MAC(OSRight, kVK_RightCommand) CODE_MAP_MAC(OSRight, kVK_RightCommand)
CODE_MAP_X11(OSRight, 0x0086) CODE_MAP_X11(OSRight, 0x0086)
CODE_MAP_ANDROID(OSRight, 0x007E)
CODE_MAP_WIN(ShiftLeft, 0x002A) CODE_MAP_WIN(ShiftLeft, 0x002A)
CODE_MAP_MAC(ShiftLeft, kVK_Shift) CODE_MAP_MAC(ShiftLeft, kVK_Shift)
CODE_MAP_X11(ShiftLeft, 0x0032) CODE_MAP_X11(ShiftLeft, 0x0032)
CODE_MAP_ANDROID(ShiftLeft, 0x002A)
CODE_MAP_WIN(ShiftRight, 0x0036) CODE_MAP_WIN(ShiftRight, 0x0036)
CODE_MAP_MAC(ShiftRight, kVK_RightShift) CODE_MAP_MAC(ShiftRight, kVK_RightShift)
CODE_MAP_X11(ShiftRight, 0x003E) CODE_MAP_X11(ShiftRight, 0x003E)
CODE_MAP_ANDROID(ShiftRight, 0x0036)
CODE_MAP_WIN(Space, 0x0039) CODE_MAP_WIN(Space, 0x0039)
CODE_MAP_MAC(Space, kVK_Space) CODE_MAP_MAC(Space, kVK_Space)
CODE_MAP_X11(Space, 0x0041) CODE_MAP_X11(Space, 0x0041)
CODE_MAP_ANDROID(Space, 0x0039)
CODE_MAP_WIN(Tab, 0x000F) CODE_MAP_WIN(Tab, 0x000F)
CODE_MAP_MAC(Tab, kVK_Tab) CODE_MAP_MAC(Tab, kVK_Tab)
CODE_MAP_X11(Tab, 0x0017) CODE_MAP_X11(Tab, 0x0017)
CODE_MAP_ANDROID(Tab, 0x000F)
// IME keys // IME keys
CODE_MAP_WIN(Convert, 0x0079) CODE_MAP_WIN(Convert, 0x0079)
CODE_MAP_X11(Convert, 0x0064) CODE_MAP_X11(Convert, 0x0064)
CODE_MAP_ANDROID(Convert, 0x005C)
CODE_MAP_WIN(Lang1, 0x0072) // for non-Korean layout CODE_MAP_WIN(Lang1, 0x0072) // for non-Korean layout
CODE_MAP_WIN(Lang1, 0xE0F2) // for Korean layout CODE_MAP_WIN(Lang1, 0xE0F2) // for Korean layout
CODE_MAP_MAC(Lang1, kVK_JIS_Kana) CODE_MAP_MAC(Lang1, kVK_JIS_Kana)
CODE_MAP_X11(Lang1, 0x0082) CODE_MAP_X11(Lang1, 0x0082)
CODE_MAP_ANDROID(Lang1, 0x007A)
CODE_MAP_WIN(Lang2, 0x0071) // for non-Korean layout CODE_MAP_WIN(Lang2, 0x0071) // for non-Korean layout
CODE_MAP_WIN(Lang2, 0xE0F1) // for Korean layout CODE_MAP_WIN(Lang2, 0xE0F1) // for Korean layout
CODE_MAP_MAC(Lang2, kVK_JIS_Eisu) CODE_MAP_MAC(Lang2, kVK_JIS_Eisu)
CODE_MAP_X11(Lang2, 0x0083) CODE_MAP_X11(Lang2, 0x0083)
CODE_MAP_ANDROID(Lang2, 0x007B)
CODE_MAP_WIN(KanaMode, 0x0070) CODE_MAP_WIN(KanaMode, 0x0070)
CODE_MAP_X11(KanaMode, 0x0065) CODE_MAP_X11(KanaMode, 0x0065)
CODE_MAP_ANDROID(KanaMode, 0x005D)
CODE_MAP_WIN(NonConvert, 0x007B) CODE_MAP_WIN(NonConvert, 0x007B)
CODE_MAP_X11(NonConvert, 0x0066) CODE_MAP_X11(NonConvert, 0x0066)
CODE_MAP_ANDROID(NonConvert, 0x005E)
// Control pad section // Control pad section
CODE_MAP_WIN(Delete, 0xE053) CODE_MAP_WIN(Delete, 0xE053)
CODE_MAP_MAC(Delete, kVK_ForwardDelete) CODE_MAP_MAC(Delete, kVK_ForwardDelete)
CODE_MAP_X11(Delete, 0x0077) CODE_MAP_X11(Delete, 0x0077)
CODE_MAP_ANDROID(Delete, 0x006F)
CODE_MAP_WIN(End, 0xE04F) CODE_MAP_WIN(End, 0xE04F)
CODE_MAP_MAC(End, kVK_End) CODE_MAP_MAC(End, kVK_End)
CODE_MAP_X11(End, 0x0073) CODE_MAP_X11(End, 0x0073)
CODE_MAP_ANDROID(End, 0x006B)
CODE_MAP_MAC(Help, kVK_Help) // Insert key on PC keyboard CODE_MAP_MAC(Help, kVK_Help) // Insert key on PC keyboard
CODE_MAP_X11(Help, 0x0092) // Help key on Sun keyboard CODE_MAP_X11(Help, 0x0092) // Help key on Sun keyboard
CODE_MAP_ANDROID(Help, 0x008A) // Help key on Sun keyboard
CODE_MAP_WIN(Home, 0xE047) CODE_MAP_WIN(Home, 0xE047)
CODE_MAP_MAC(Home, kVK_Home) CODE_MAP_MAC(Home, kVK_Home)
CODE_MAP_X11(Home, 0x006E) CODE_MAP_X11(Home, 0x006E)
CODE_MAP_ANDROID(Home, 0x0066)
CODE_MAP_WIN(Insert, 0xE052) CODE_MAP_WIN(Insert, 0xE052)
CODE_MAP_X11(Insert, 0x0076) CODE_MAP_X11(Insert, 0x0076)
CODE_MAP_ANDROID(Insert, 0x006E)
CODE_MAP_WIN(PageDown, 0xE051) CODE_MAP_WIN(PageDown, 0xE051)
CODE_MAP_MAC(PageDown, kVK_PageDown) CODE_MAP_MAC(PageDown, kVK_PageDown)
CODE_MAP_X11(PageDown, 0x0075) CODE_MAP_X11(PageDown, 0x0075)
CODE_MAP_ANDROID(PageDown, 0x006D)
CODE_MAP_WIN(PageUp, 0xE049) CODE_MAP_WIN(PageUp, 0xE049)
CODE_MAP_MAC(PageUp, kVK_PageUp) CODE_MAP_MAC(PageUp, kVK_PageUp)
CODE_MAP_X11(PageUp, 0x0070) CODE_MAP_X11(PageUp, 0x0070)
CODE_MAP_ANDROID(PageUp, 0x0068)
// Arrow pad section // Arrow pad section
CODE_MAP_WIN(ArrowDown, 0xE050) CODE_MAP_WIN(ArrowDown, 0xE050)
CODE_MAP_MAC(ArrowDown, kVK_DownArrow) CODE_MAP_MAC(ArrowDown, kVK_DownArrow)
CODE_MAP_X11(ArrowDown, 0x0074) CODE_MAP_X11(ArrowDown, 0x0074)
CODE_MAP_ANDROID(ArrowDown, 0x006C)
CODE_MAP_WIN(ArrowLeft, 0xE04B) CODE_MAP_WIN(ArrowLeft, 0xE04B)
CODE_MAP_MAC(ArrowLeft, kVK_LeftArrow) CODE_MAP_MAC(ArrowLeft, kVK_LeftArrow)
CODE_MAP_X11(ArrowLeft, 0x0071) CODE_MAP_X11(ArrowLeft, 0x0071)
CODE_MAP_ANDROID(ArrowLeft, 0x0069)
CODE_MAP_WIN(ArrowRight, 0xE04D) CODE_MAP_WIN(ArrowRight, 0xE04D)
CODE_MAP_MAC(ArrowRight, kVK_RightArrow) CODE_MAP_MAC(ArrowRight, kVK_RightArrow)
CODE_MAP_X11(ArrowRight, 0x0072) CODE_MAP_X11(ArrowRight, 0x0072)
CODE_MAP_ANDROID(ArrowRight, 0x006A)
CODE_MAP_WIN(ArrowUp, 0xE048) CODE_MAP_WIN(ArrowUp, 0xE048)
CODE_MAP_MAC(ArrowUp, kVK_UpArrow) CODE_MAP_MAC(ArrowUp, kVK_UpArrow)
CODE_MAP_X11(ArrowUp, 0x006F) CODE_MAP_X11(ArrowUp, 0x006F)
CODE_MAP_ANDROID(ArrowUp, 0x0067)
// Numpad section // Numpad section
CODE_MAP_WIN(NumLock, 0xE045) // MSDN says 0x0045, though... CODE_MAP_WIN(NumLock, 0xE045) // MSDN says 0x0045, though...
CODE_MAP_MAC(NumLock, kVK_ANSI_KeypadClear) CODE_MAP_MAC(NumLock, kVK_ANSI_KeypadClear)
CODE_MAP_X11(NumLock, 0x004D) CODE_MAP_X11(NumLock, 0x004D)
CODE_MAP_ANDROID(NumLock, 0x0045)
CODE_MAP_WIN(Numpad0, 0x0052) CODE_MAP_WIN(Numpad0, 0x0052)
CODE_MAP_MAC(Numpad0, kVK_ANSI_Keypad0) CODE_MAP_MAC(Numpad0, kVK_ANSI_Keypad0)
CODE_MAP_X11(Numpad0, 0x005A) CODE_MAP_X11(Numpad0, 0x005A)
CODE_MAP_ANDROID(Numpad0, 0x0052)
CODE_MAP_WIN(Numpad1, 0x004F) CODE_MAP_WIN(Numpad1, 0x004F)
CODE_MAP_MAC(Numpad1, kVK_ANSI_Keypad1) CODE_MAP_MAC(Numpad1, kVK_ANSI_Keypad1)
CODE_MAP_X11(Numpad1, 0x0057) CODE_MAP_X11(Numpad1, 0x0057)
CODE_MAP_ANDROID(Numpad1, 0x004F)
CODE_MAP_WIN(Numpad2, 0x0050) CODE_MAP_WIN(Numpad2, 0x0050)
CODE_MAP_MAC(Numpad2, kVK_ANSI_Keypad2) CODE_MAP_MAC(Numpad2, kVK_ANSI_Keypad2)
CODE_MAP_X11(Numpad2, 0x0058) CODE_MAP_X11(Numpad2, 0x0058)
CODE_MAP_ANDROID(Numpad2, 0x0050)
CODE_MAP_WIN(Numpad3, 0x0051) CODE_MAP_WIN(Numpad3, 0x0051)
CODE_MAP_MAC(Numpad3, kVK_ANSI_Keypad3) CODE_MAP_MAC(Numpad3, kVK_ANSI_Keypad3)
CODE_MAP_X11(Numpad3, 0x0059) CODE_MAP_X11(Numpad3, 0x0059)
CODE_MAP_ANDROID(Numpad3, 0x0051)
CODE_MAP_WIN(Numpad4, 0x004B) CODE_MAP_WIN(Numpad4, 0x004B)
CODE_MAP_MAC(Numpad4, kVK_ANSI_Keypad4) CODE_MAP_MAC(Numpad4, kVK_ANSI_Keypad4)
CODE_MAP_X11(Numpad4, 0x0053) CODE_MAP_X11(Numpad4, 0x0053)
CODE_MAP_ANDROID(Numpad4, 0x004B)
CODE_MAP_WIN(Numpad5, 0x004C) CODE_MAP_WIN(Numpad5, 0x004C)
CODE_MAP_MAC(Numpad5, kVK_ANSI_Keypad5) CODE_MAP_MAC(Numpad5, kVK_ANSI_Keypad5)
CODE_MAP_X11(Numpad5, 0x0054) CODE_MAP_X11(Numpad5, 0x0054)
CODE_MAP_ANDROID(Numpad5, 0x004C)
CODE_MAP_WIN(Numpad6, 0x004D) CODE_MAP_WIN(Numpad6, 0x004D)
CODE_MAP_MAC(Numpad6, kVK_ANSI_Keypad6) CODE_MAP_MAC(Numpad6, kVK_ANSI_Keypad6)
CODE_MAP_X11(Numpad6, 0x0055) CODE_MAP_X11(Numpad6, 0x0055)
CODE_MAP_ANDROID(Numpad6, 0x004D)
CODE_MAP_WIN(Numpad7, 0x0047) CODE_MAP_WIN(Numpad7, 0x0047)
CODE_MAP_MAC(Numpad7, kVK_ANSI_Keypad7) CODE_MAP_MAC(Numpad7, kVK_ANSI_Keypad7)
CODE_MAP_X11(Numpad7, 0x004F) CODE_MAP_X11(Numpad7, 0x004F)
CODE_MAP_ANDROID(Numpad7, 0x0047)
CODE_MAP_WIN(Numpad8, 0x0048) CODE_MAP_WIN(Numpad8, 0x0048)
CODE_MAP_MAC(Numpad8, kVK_ANSI_Keypad8) CODE_MAP_MAC(Numpad8, kVK_ANSI_Keypad8)
CODE_MAP_X11(Numpad8, 0x0050) CODE_MAP_X11(Numpad8, 0x0050)
CODE_MAP_ANDROID(Numpad8, 0x0048)
CODE_MAP_WIN(Numpad9, 0x0049) CODE_MAP_WIN(Numpad9, 0x0049)
CODE_MAP_MAC(Numpad9, kVK_ANSI_Keypad9) CODE_MAP_MAC(Numpad9, kVK_ANSI_Keypad9)
CODE_MAP_X11(Numpad9, 0x0051) CODE_MAP_X11(Numpad9, 0x0051)
CODE_MAP_ANDROID(Numpad9, 0x0049)
CODE_MAP_WIN(NumpadAdd, 0x004E) CODE_MAP_WIN(NumpadAdd, 0x004E)
CODE_MAP_MAC(NumpadAdd, kVK_ANSI_KeypadPlus) CODE_MAP_MAC(NumpadAdd, kVK_ANSI_KeypadPlus)
CODE_MAP_X11(NumpadAdd, 0x0056) CODE_MAP_X11(NumpadAdd, 0x0056)
CODE_MAP_ANDROID(NumpadAdd, 0x004E)
CODE_MAP_WIN(NumpadComma, 0x007E) CODE_MAP_WIN(NumpadComma, 0x007E)
CODE_MAP_MAC(NumpadComma, kVK_JIS_KeypadComma) CODE_MAP_MAC(NumpadComma, kVK_JIS_KeypadComma)
CODE_MAP_X11(NumpadComma, 0x0081) CODE_MAP_X11(NumpadComma, 0x0081)
CODE_MAP_ANDROID(NumpadComma, 0x0079)
CODE_MAP_WIN(NumpadDecimal, 0x0053) CODE_MAP_WIN(NumpadDecimal, 0x0053)
CODE_MAP_MAC(NumpadDecimal, kVK_ANSI_KeypadDecimal) CODE_MAP_MAC(NumpadDecimal, kVK_ANSI_KeypadDecimal)
CODE_MAP_X11(NumpadDecimal, 0x005B) CODE_MAP_X11(NumpadDecimal, 0x005B)
CODE_MAP_ANDROID(NumpadDecimal, 0x0053)
CODE_MAP_WIN(NumpadDivide, 0xE035) CODE_MAP_WIN(NumpadDivide, 0xE035)
CODE_MAP_MAC(NumpadDivide, kVK_ANSI_KeypadDivide) CODE_MAP_MAC(NumpadDivide, kVK_ANSI_KeypadDivide)
CODE_MAP_X11(NumpadDivide, 0x006A) CODE_MAP_X11(NumpadDivide, 0x006A)
CODE_MAP_ANDROID(NumpadDivide, 0x0062)
CODE_MAP_WIN(NumpadEnter, 0xE01C) CODE_MAP_WIN(NumpadEnter, 0xE01C)
CODE_MAP_MAC(NumpadEnter, kVK_ANSI_KeypadEnter) CODE_MAP_MAC(NumpadEnter, kVK_ANSI_KeypadEnter)
CODE_MAP_MAC(NumpadEnter, kVK_Powerbook_KeypadEnter) CODE_MAP_MAC(NumpadEnter, kVK_Powerbook_KeypadEnter)
CODE_MAP_X11(NumpadEnter, 0x0068) CODE_MAP_X11(NumpadEnter, 0x0068)
CODE_MAP_ANDROID(NumpadEnter, 0x0060)
CODE_MAP_WIN(NumpadEqual, 0x0059) CODE_MAP_WIN(NumpadEqual, 0x0059)
CODE_MAP_MAC(NumpadEqual, kVK_ANSI_KeypadEquals) CODE_MAP_MAC(NumpadEqual, kVK_ANSI_KeypadEquals)
CODE_MAP_X11(NumpadEqual, 0x007D) CODE_MAP_X11(NumpadEqual, 0x007D)
CODE_MAP_ANDROID(NumpadEqual, 0x0075)
CODE_MAP_WIN(NumpadMultiply, 0x0037) CODE_MAP_WIN(NumpadMultiply, 0x0037)
CODE_MAP_MAC(NumpadMultiply, kVK_ANSI_KeypadMultiply) CODE_MAP_MAC(NumpadMultiply, kVK_ANSI_KeypadMultiply)
CODE_MAP_X11(NumpadMultiply, 0x003F) CODE_MAP_X11(NumpadMultiply, 0x003F)
CODE_MAP_ANDROID(NumpadMultiply, 0x0037)
CODE_MAP_WIN(NumpadSubtract, 0x004A) CODE_MAP_WIN(NumpadSubtract, 0x004A)
CODE_MAP_MAC(NumpadSubtract, kVK_ANSI_KeypadMinus) CODE_MAP_MAC(NumpadSubtract, kVK_ANSI_KeypadMinus)
CODE_MAP_X11(NumpadSubtract, 0x0052) CODE_MAP_X11(NumpadSubtract, 0x0052)
CODE_MAP_ANDROID(NumpadSubtract, 0x004A)
// Function section // Function section
CODE_MAP_WIN(Escape, 0x0001) CODE_MAP_WIN(Escape, 0x0001)
CODE_MAP_MAC(Escape, kVK_Escape) CODE_MAP_MAC(Escape, kVK_Escape)
CODE_MAP_X11(Escape, 0x0009) CODE_MAP_X11(Escape, 0x0009)
CODE_MAP_ANDROID(Escape, 0x0001)
CODE_MAP_WIN(F1, 0x003B) CODE_MAP_WIN(F1, 0x003B)
CODE_MAP_MAC(F1, kVK_F1) CODE_MAP_MAC(F1, kVK_F1)
CODE_MAP_X11(F1, 0x0043) CODE_MAP_X11(F1, 0x0043)
CODE_MAP_ANDROID(F1, 0x003B)
CODE_MAP_WIN(F2, 0x003C) CODE_MAP_WIN(F2, 0x003C)
CODE_MAP_MAC(F2, kVK_F2) CODE_MAP_MAC(F2, kVK_F2)
CODE_MAP_X11(F2, 0x0044) CODE_MAP_X11(F2, 0x0044)
CODE_MAP_ANDROID(F2, 0x003C)
CODE_MAP_WIN(F3, 0x003D) CODE_MAP_WIN(F3, 0x003D)
CODE_MAP_MAC(F3, kVK_F3) CODE_MAP_MAC(F3, kVK_F3)
CODE_MAP_X11(F3, 0x0045) CODE_MAP_X11(F3, 0x0045)
CODE_MAP_ANDROID(F3, 0x003D)
CODE_MAP_WIN(F4, 0x003E) CODE_MAP_WIN(F4, 0x003E)
CODE_MAP_MAC(F4, kVK_F4) CODE_MAP_MAC(F4, kVK_F4)
CODE_MAP_X11(F4, 0x0046) CODE_MAP_X11(F4, 0x0046)
CODE_MAP_ANDROID(F4, 0x003E)
CODE_MAP_WIN(F5, 0x003F) CODE_MAP_WIN(F5, 0x003F)
CODE_MAP_MAC(F5, kVK_F5) CODE_MAP_MAC(F5, kVK_F5)
CODE_MAP_X11(F5, 0x0047) CODE_MAP_X11(F5, 0x0047)
CODE_MAP_ANDROID(F5, 0x003F)
CODE_MAP_WIN(F6, 0x0040) CODE_MAP_WIN(F6, 0x0040)
CODE_MAP_MAC(F6, kVK_F6) CODE_MAP_MAC(F6, kVK_F6)
CODE_MAP_X11(F6, 0x0048) CODE_MAP_X11(F6, 0x0048)
CODE_MAP_ANDROID(F6, 0x0040)
CODE_MAP_WIN(F7, 0x0041) CODE_MAP_WIN(F7, 0x0041)
CODE_MAP_MAC(F7, kVK_F7) CODE_MAP_MAC(F7, kVK_F7)
CODE_MAP_X11(F7, 0x0049) CODE_MAP_X11(F7, 0x0049)
CODE_MAP_ANDROID(F7, 0x0041)
CODE_MAP_WIN(F8, 0x0042) CODE_MAP_WIN(F8, 0x0042)
CODE_MAP_MAC(F8, kVK_F8) CODE_MAP_MAC(F8, kVK_F8)
CODE_MAP_X11(F8, 0x004A) CODE_MAP_X11(F8, 0x004A)
CODE_MAP_ANDROID(F8, 0x0042)
CODE_MAP_WIN(F9, 0x0043) CODE_MAP_WIN(F9, 0x0043)
CODE_MAP_MAC(F9, kVK_F9) CODE_MAP_MAC(F9, kVK_F9)
CODE_MAP_X11(F9, 0x004B) CODE_MAP_X11(F9, 0x004B)
CODE_MAP_ANDROID(F9, 0x0043)
CODE_MAP_WIN(F10, 0x0044) CODE_MAP_WIN(F10, 0x0044)
CODE_MAP_MAC(F10, kVK_F10) CODE_MAP_MAC(F10, kVK_F10)
CODE_MAP_X11(F10, 0x004C) CODE_MAP_X11(F10, 0x004C)
CODE_MAP_ANDROID(F10, 0x0044)
CODE_MAP_WIN(F11, 0x0057) CODE_MAP_WIN(F11, 0x0057)
CODE_MAP_MAC(F11, kVK_F11) CODE_MAP_MAC(F11, kVK_F11)
CODE_MAP_X11(F11, 0x005F) CODE_MAP_X11(F11, 0x005F)
CODE_MAP_ANDROID(F11, 0x0057)
CODE_MAP_WIN(F12, 0x0058) CODE_MAP_WIN(F12, 0x0058)
CODE_MAP_MAC(F12, kVK_F12) CODE_MAP_MAC(F12, kVK_F12)
CODE_MAP_X11(F12, 0x0060) CODE_MAP_X11(F12, 0x0060)
CODE_MAP_ANDROID(F12, 0x0058)
CODE_MAP_WIN(F13, 0x0064) CODE_MAP_WIN(F13, 0x0064)
CODE_MAP_MAC(F13, kVK_F13) // PrintScreen on PC keyboard CODE_MAP_MAC(F13, kVK_F13) // PrintScreen on PC keyboard
CODE_MAP_X11(F13, 0x00BF) CODE_MAP_X11(F13, 0x00BF)
CODE_MAP_ANDROID(F13, 0x00B7)
CODE_MAP_WIN(F14, 0x0065) CODE_MAP_WIN(F14, 0x0065)
CODE_MAP_MAC(F14, kVK_F14) // ScrollLock on PC keyboard CODE_MAP_MAC(F14, kVK_F14) // ScrollLock on PC keyboard
CODE_MAP_X11(F14, 0x00C0) CODE_MAP_X11(F14, 0x00C0)
CODE_MAP_ANDROID(F14, 0x00B8)
CODE_MAP_WIN(F15, 0x0066) CODE_MAP_WIN(F15, 0x0066)
CODE_MAP_MAC(F15, kVK_F15) // Pause on PC keyboard CODE_MAP_MAC(F15, kVK_F15) // Pause on PC keyboard
CODE_MAP_X11(F15, 0x00C1) CODE_MAP_X11(F15, 0x00C1)
CODE_MAP_ANDROID(F15, 0x00B9)
CODE_MAP_WIN(F16, 0x0067) CODE_MAP_WIN(F16, 0x0067)
CODE_MAP_MAC(F16, kVK_F16) CODE_MAP_MAC(F16, kVK_F16)
CODE_MAP_X11(F16, 0x00C2) CODE_MAP_X11(F16, 0x00C2)
CODE_MAP_ANDROID(F16, 0x00BA)
CODE_MAP_WIN(F17, 0x0068) CODE_MAP_WIN(F17, 0x0068)
CODE_MAP_MAC(F17, kVK_F17) CODE_MAP_MAC(F17, kVK_F17)
CODE_MAP_X11(F17, 0x00C3) CODE_MAP_X11(F17, 0x00C3)
CODE_MAP_ANDROID(F17, 0x00BB)
CODE_MAP_WIN(F18, 0x0069) CODE_MAP_WIN(F18, 0x0069)
CODE_MAP_MAC(F18, kVK_F18) CODE_MAP_MAC(F18, kVK_F18)
CODE_MAP_X11(F18, 0x00C4) CODE_MAP_X11(F18, 0x00C4)
CODE_MAP_ANDROID(F18, 0x00BC)
CODE_MAP_WIN(F19, 0x006A) CODE_MAP_WIN(F19, 0x006A)
CODE_MAP_MAC(F19, kVK_F19) CODE_MAP_MAC(F19, kVK_F19)
CODE_MAP_X11(F19, 0x00C5) CODE_MAP_X11(F19, 0x00C5)
CODE_MAP_ANDROID(F19, 0x00BD)
CODE_MAP_WIN(F20, 0x006B) CODE_MAP_WIN(F20, 0x006B)
CODE_MAP_MAC(F20, kVK_F20) CODE_MAP_MAC(F20, kVK_F20)
CODE_MAP_X11(F20, 0x00C6) CODE_MAP_X11(F20, 0x00C6)
CODE_MAP_ANDROID(F20, 0x00BE)
CODE_MAP_WIN(F21, 0x006C) CODE_MAP_WIN(F21, 0x006C)
CODE_MAP_X11(F21, 0x00C7) CODE_MAP_X11(F21, 0x00C7)
CODE_MAP_ANDROID(F21, 0x00BF)
CODE_MAP_WIN(F22, 0x006D) CODE_MAP_WIN(F22, 0x006D)
CODE_MAP_X11(F22, 0x00C8) CODE_MAP_X11(F22, 0x00C8)
CODE_MAP_ANDROID(F22, 0x00C0)
CODE_MAP_WIN(F23, 0x006E) CODE_MAP_WIN(F23, 0x006E)
CODE_MAP_X11(F23, 0x00C9) CODE_MAP_X11(F23, 0x00C9)
CODE_MAP_ANDROID(F23, 0x00C1)
CODE_MAP_WIN(F24, 0x0076) CODE_MAP_WIN(F24, 0x0076)
CODE_MAP_X11(F24, 0x00CA) CODE_MAP_X11(F24, 0x00CA)
CODE_MAP_ANDROID(F24, 0x00C2)
CODE_MAP_MAC(Fn, kVK_Function) // not available? CODE_MAP_MAC(Fn, kVK_Function) // not available?
CODE_MAP_ANDROID(Fn, 0x01D0)
CODE_MAP_WIN(PrintScreen, 0xE037) CODE_MAP_WIN(PrintScreen, 0xE037)
CODE_MAP_WIN(PrintScreen, 0x0054) // Alt + PrintScreen CODE_MAP_WIN(PrintScreen, 0x0054) // Alt + PrintScreen
CODE_MAP_X11(PrintScreen, 0x006B) CODE_MAP_X11(PrintScreen, 0x006B)
CODE_MAP_ANDROID(PrintScreen, 0x0063)
CODE_MAP_WIN(ScrollLock, 0x0046) CODE_MAP_WIN(ScrollLock, 0x0046)
CODE_MAP_X11(ScrollLock, 0x004E) CODE_MAP_X11(ScrollLock, 0x004E)
CODE_MAP_ANDROID(ScrollLock, 0x0046)
CODE_MAP_WIN(Pause, 0x0045) CODE_MAP_WIN(Pause, 0x0045)
CODE_MAP_WIN(Pause, 0xE046) // Ctrl + Pause CODE_MAP_WIN(Pause, 0xE046) // Ctrl + Pause
CODE_MAP_X11(Pause, 0x007F) CODE_MAP_X11(Pause, 0x007F)
CODE_MAP_ANDROID(Pause, 0x0077)
// Media keys // Media keys
CODE_MAP_WIN(BrowserBack, 0xE06A) CODE_MAP_WIN(BrowserBack, 0xE06A)
CODE_MAP_X11(BrowserBack, 0x00A6) CODE_MAP_X11(BrowserBack, 0x00A6)
CODE_MAP_ANDROID(BrowserBack, 0x009E)
CODE_MAP_WIN(BrowserFavorites, 0xE066) CODE_MAP_WIN(BrowserFavorites, 0xE066)
CODE_MAP_X11(BrowserFavorites, 0x00A4) CODE_MAP_X11(BrowserFavorites, 0x00A4)
CODE_MAP_ANDROID(BrowserFavorites, 0x009C)
CODE_MAP_WIN(BrowserForward, 0xE069) CODE_MAP_WIN(BrowserForward, 0xE069)
CODE_MAP_X11(BrowserForward, 0x00A7) CODE_MAP_X11(BrowserForward, 0x00A7)
CODE_MAP_ANDROID(BrowserForward, 0x009F)
CODE_MAP_WIN(BrowserHome, 0xE032) CODE_MAP_WIN(BrowserHome, 0xE032)
CODE_MAP_X11(BrowserHome, 0x00B4) CODE_MAP_X11(BrowserHome, 0x00B4)
// CODE_MAP_ANDROID(BrowserHome) // not available? works as Home key.
CODE_MAP_WIN(BrowserRefresh, 0xE067) CODE_MAP_WIN(BrowserRefresh, 0xE067)
CODE_MAP_X11(BrowserRefresh, 0x00B5) CODE_MAP_X11(BrowserRefresh, 0x00B5)
CODE_MAP_ANDROID(BrowserRefresh, 0x00AD)
CODE_MAP_WIN(BrowserSearch, 0xE065) CODE_MAP_WIN(BrowserSearch, 0xE065)
CODE_MAP_X11(BrowserSearch, 0x00E1) CODE_MAP_X11(BrowserSearch, 0x00E1)
CODE_MAP_ANDROID(BrowserSearch, 0x00D9)
CODE_MAP_WIN(BrowserStop, 0xE068) CODE_MAP_WIN(BrowserStop, 0xE068)
CODE_MAP_X11(BrowserStop, 0x0088) CODE_MAP_X11(BrowserStop, 0x0088)
CODE_MAP_ANDROID(BrowserStop, 0x0080)
// CODE_MAP_WIN(Eject) // not available? // CODE_MAP_WIN(Eject) // not available?
// CODE_MAP_MAC(Eject) // not available? // CODE_MAP_MAC(Eject) // not available?
CODE_MAP_X11(Eject, 0x00A9) CODE_MAP_X11(Eject, 0x00A9)
CODE_MAP_ANDROID(Eject, 0x00A1)
CODE_MAP_WIN(LaunchApp1, 0xE06B) CODE_MAP_WIN(LaunchApp1, 0xE06B)
CODE_MAP_X11(LaunchApp1, 0x0098) CODE_MAP_X11(LaunchApp1, 0x0098)
CODE_MAP_ANDROID(LaunchApp1, 0x0090)
CODE_MAP_WIN(LaunchApp2, 0xE021) CODE_MAP_WIN(LaunchApp2, 0xE021)
CODE_MAP_X11(LaunchApp2, 0x0094) CODE_MAP_X11(LaunchApp2, 0x0094)
// CODE_MAP_ANDROID(LaunchApp2) // not available?
CODE_MAP_WIN(LaunchMail, 0xE06C) CODE_MAP_WIN(LaunchMail, 0xE06C)
CODE_MAP_X11(LaunchMail, 0x00A3) CODE_MAP_X11(LaunchMail, 0x00A3)
// CODE_MAP_ANDROID(LaunchMail) // not available?
CODE_MAP_WIN(MediaPlayPause, 0xE022) CODE_MAP_WIN(MediaPlayPause, 0xE022)
CODE_MAP_X11(MediaPlayPause, 0x00AC) CODE_MAP_X11(MediaPlayPause, 0x00AC)
CODE_MAP_ANDROID(MediaPlayPause, 0x00A4)
CODE_MAP_WIN(MediaSelect, 0xE06D) CODE_MAP_WIN(MediaSelect, 0xE06D)
CODE_MAP_X11(MediaSelect, 0x00B3) CODE_MAP_X11(MediaSelect, 0x00B3)
// CODE_MAP_ANDROID(MediaSelect) // not available?
CODE_MAP_WIN(MediaStop, 0xE024) CODE_MAP_WIN(MediaStop, 0xE024)
CODE_MAP_X11(MediaStop, 0x00AE) CODE_MAP_X11(MediaStop, 0x00AE)
CODE_MAP_ANDROID(MediaStop, 0x00A6)
CODE_MAP_WIN(MediaTrackNext, 0xE019) CODE_MAP_WIN(MediaTrackNext, 0xE019)
CODE_MAP_X11(MediaTrackNext, 0x00AB) CODE_MAP_X11(MediaTrackNext, 0x00AB)
CODE_MAP_ANDROID(MediaTrackNext, 0x00A3)
CODE_MAP_WIN(MediaTrackPrevious, 0xE010) CODE_MAP_WIN(MediaTrackPrevious, 0xE010)
CODE_MAP_X11(MediaTrackPrevious, 0x00AD) CODE_MAP_X11(MediaTrackPrevious, 0x00AD)
CODE_MAP_ANDROID(MediaTrackPrevious, 0x00A5)
CODE_MAP_WIN(Power, 0xE05E) CODE_MAP_WIN(Power, 0xE05E)
CODE_MAP_MAC(Power, 0x007F) // On 10.7 and 10.8 only CODE_MAP_MAC(Power, 0x007F) // On 10.7 and 10.8 only
// CODE_MAP_X11(Power) // not available? // CODE_MAP_X11(Power) // not available?
CODE_MAP_ANDROID(Power, 0x0074)
// CODE_MAP_WIN(Sleep) // not available? // CODE_MAP_WIN(Sleep) // not available?
// CODE_MAP_X11(Sleep) // not available? // CODE_MAP_X11(Sleep) // not available?
CODE_MAP_ANDROID(Sleep, 0x008E)
CODE_MAP_WIN(VolumeDown, 0xE02E) CODE_MAP_WIN(VolumeDown, 0xE02E)
CODE_MAP_MAC(VolumeDown, kVK_VolumeDown) // not available? CODE_MAP_MAC(VolumeDown, kVK_VolumeDown) // not available?
CODE_MAP_X11(VolumeDown, 0x007A) CODE_MAP_X11(VolumeDown, 0x007A)
CODE_MAP_ANDROID(VolumeDown, 0x0072)
CODE_MAP_WIN(VolumeMute, 0xE020) CODE_MAP_WIN(VolumeMute, 0xE020)
CODE_MAP_MAC(VolumeMute, kVK_Mute) // not available? CODE_MAP_MAC(VolumeMute, kVK_Mute) // not available?
CODE_MAP_X11(VolumeMute, 0x0079) CODE_MAP_X11(VolumeMute, 0x0079)
CODE_MAP_ANDROID(VolumeMute, 0x0071)
CODE_MAP_WIN(VolumeUp, 0xE030) CODE_MAP_WIN(VolumeUp, 0xE030)
CODE_MAP_MAC(VolumeUp, kVK_VolumeUp) // not available? CODE_MAP_MAC(VolumeUp, kVK_VolumeUp) // not available?
CODE_MAP_X11(VolumeUp, 0x007B) CODE_MAP_X11(VolumeUp, 0x007B)
CODE_MAP_ANDROID(VolumeUp, 0x0073) // side of body, not on keyboard
// CODE_MAP_WIN(WakeUp) // not available? // CODE_MAP_WIN(WakeUp) // not available?
CODE_MAP_X11(WakeUp, 0x0097) CODE_MAP_X11(WakeUp, 0x0097)
CODE_MAP_ANDROID(WakeUp, 0x008F)
// Legacy editing keys // Legacy editing keys
CODE_MAP_X11(Again, 0x0089) // Again key on Sun keyboard CODE_MAP_X11(Again, 0x0089) // Again key on Sun keyboard
CODE_MAP_ANDROID(Again, 0x0081) // Again key on Sun keyboard
CODE_MAP_X11(Copy, 0x008D) // Copy key on Sun keyboard CODE_MAP_X11(Copy, 0x008D) // Copy key on Sun keyboard
CODE_MAP_ANDROID(Copy, 0x0085) // Copy key on Sun keyboard
CODE_MAP_X11(Cut, 0x0091) // Cut key on Sun keyboard CODE_MAP_X11(Cut, 0x0091) // Cut key on Sun keyboard
CODE_MAP_ANDROID(Cut, 0x0089) // Cut key on Sun keyboard
CODE_MAP_X11(Find, 0x0090) // Find key on Sun keyboard CODE_MAP_X11(Find, 0x0090) // Find key on Sun keyboard
CODE_MAP_ANDROID(Find, 0x0088) // Find key on Sun keyboard
CODE_MAP_X11(Open, 0x008E) // Open key on Sun keyboard CODE_MAP_X11(Open, 0x008E) // Open key on Sun keyboard
CODE_MAP_ANDROID(Open, 0x0086) // Open key on Sun keyboard
CODE_MAP_X11(Paste, 0x008F) // Paste key on Sun keyboard CODE_MAP_X11(Paste, 0x008F) // Paste key on Sun keyboard
CODE_MAP_ANDROID(Paste, 0x0087) // Paste key on Sun keyboard
CODE_MAP_X11(Props, 0x008A) // Props key on Sun keyboard CODE_MAP_X11(Props, 0x008A) // Props key on Sun keyboard
CODE_MAP_ANDROID(Props, 0x0082) // Props key on Sun keyboard
CODE_MAP_X11(Select, 0x008C) // Front key on Sun keyboard CODE_MAP_X11(Select, 0x008C) // Front key on Sun keyboard
CODE_MAP_ANDROID(Select, 0x0084) // Front key on Sun keyboard
CODE_MAP_X11(Undo, 0x008B) // Undo key on Sun keyboard CODE_MAP_X11(Undo, 0x008B) // Undo key on Sun keyboard
CODE_MAP_ANDROID(Undo, 0x0083) // Undo key on Sun keyboard
#undef CODE_MAP_WIN #undef CODE_MAP_WIN
#undef CODE_MAP_MAC #undef CODE_MAP_MAC
#undef CODE_MAP_X11 #undef CODE_MAP_X11
#undef CODE_MAP_ANDROID

View file

@ -25,7 +25,6 @@
#define KEY_MAP_COCOA(aCPPKeyName, aNativeKey) #define KEY_MAP_COCOA(aCPPKeyName, aNativeKey)
// GTK // GTK
#define KEY_MAP_GTK(aCPPKeyName, aNativeKey) #define KEY_MAP_GTK(aCPPKeyName, aNativeKey)
#define KEY_MAP_ANDROID(aCPPKeyName, aNativeKey)
#if defined(XP_WIN) #if defined(XP_WIN)
#if defined(NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX) #if defined(NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX)
@ -71,10 +70,6 @@
#undef KEY_MAP_GTK #undef KEY_MAP_GTK
#define KEY_MAP_GTK(aCPPKeyName, aNativeKey) \ #define KEY_MAP_GTK(aCPPKeyName, aNativeKey) \
NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName) NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName)
#elif defined(ANDROID)
#undef KEY_MAP_ANDROID
#define KEY_MAP_ANDROID(aCPPKeyName, aNativeKey) \
NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, KEY_NAME_INDEX_##aCPPKeyName)
#endif #endif
/****************************************************************************** /******************************************************************************
@ -88,8 +83,6 @@ KEY_MAP_COCOA (Alt, kVK_Option)
KEY_MAP_COCOA (Alt, kVK_RightOption) KEY_MAP_COCOA (Alt, kVK_RightOption)
KEY_MAP_GTK (Alt, GDK_Alt_L) KEY_MAP_GTK (Alt, GDK_Alt_L)
KEY_MAP_GTK (Alt, GDK_Alt_R) KEY_MAP_GTK (Alt, GDK_Alt_R)
KEY_MAP_ANDROID (Alt, AKEYCODE_ALT_LEFT)
KEY_MAP_ANDROID (Alt, AKEYCODE_ALT_RIGHT)
// AltGraph // AltGraph
KEY_MAP_GTK (AltGraph, GDK_Mode_switch /* same as GDK_kana_switch, KEY_MAP_GTK (AltGraph, GDK_Mode_switch /* same as GDK_kana_switch,
@ -109,7 +102,6 @@ KEY_MAP_GTK (AltGraph, GDK_ISO_Level5_Lock)
KEY_MAP_WIN (CapsLock, VK_CAPITAL) KEY_MAP_WIN (CapsLock, VK_CAPITAL)
KEY_MAP_COCOA (CapsLock, kVK_CapsLock) KEY_MAP_COCOA (CapsLock, kVK_CapsLock)
KEY_MAP_GTK (CapsLock, GDK_Caps_Lock) KEY_MAP_GTK (CapsLock, GDK_Caps_Lock)
KEY_MAP_ANDROID (CapsLock, AKEYCODE_CAPS_LOCK)
// Control // Control
KEY_MAP_WIN (Control, VK_CONTROL) KEY_MAP_WIN (Control, VK_CONTROL)
@ -119,25 +111,19 @@ KEY_MAP_COCOA (Control, kVK_Control)
KEY_MAP_COCOA (Control, kVK_RightControl) KEY_MAP_COCOA (Control, kVK_RightControl)
KEY_MAP_GTK (Control, GDK_Control_L) KEY_MAP_GTK (Control, GDK_Control_L)
KEY_MAP_GTK (Control, GDK_Control_R) KEY_MAP_GTK (Control, GDK_Control_R)
KEY_MAP_ANDROID (Control, AKEYCODE_CTRL_LEFT)
KEY_MAP_ANDROID (Control, AKEYCODE_CTRL_RIGHT)
// Fn // Fn
KEY_MAP_COCOA (Fn, kVK_Function) KEY_MAP_COCOA (Fn, kVK_Function)
KEY_MAP_ANDROID (Fn, AKEYCODE_FUNCTION)
// Meta // Meta
KEY_MAP_COCOA (Meta, kVK_Command) KEY_MAP_COCOA (Meta, kVK_Command)
KEY_MAP_COCOA (Meta, kVK_RightCommand) KEY_MAP_COCOA (Meta, kVK_RightCommand)
KEY_MAP_GTK (Meta, GDK_Meta_L) KEY_MAP_GTK (Meta, GDK_Meta_L)
KEY_MAP_GTK (Meta, GDK_Meta_R) KEY_MAP_GTK (Meta, GDK_Meta_R)
KEY_MAP_ANDROID (Meta, AKEYCODE_META_LEFT)
KEY_MAP_ANDROID (Meta, AKEYCODE_META_RIGHT)
// NumLock // NumLock
KEY_MAP_WIN (NumLock, VK_NUMLOCK) KEY_MAP_WIN (NumLock, VK_NUMLOCK)
KEY_MAP_GTK (NumLock, GDK_Num_Lock) KEY_MAP_GTK (NumLock, GDK_Num_Lock)
KEY_MAP_ANDROID (NumLock, AKEYCODE_NUM_LOCK)
// OS // OS
KEY_MAP_WIN (OS, VK_LWIN) KEY_MAP_WIN (OS, VK_LWIN)
@ -150,7 +136,6 @@ KEY_MAP_GTK (OS, GDK_Hyper_R)
// ScrollLock // ScrollLock
KEY_MAP_WIN (ScrollLock, VK_SCROLL) KEY_MAP_WIN (ScrollLock, VK_SCROLL)
KEY_MAP_GTK (ScrollLock, GDK_Scroll_Lock) KEY_MAP_GTK (ScrollLock, GDK_Scroll_Lock)
KEY_MAP_ANDROID (ScrollLock, AKEYCODE_SCROLL_LOCK)
// Shift // Shift
KEY_MAP_WIN (Shift, VK_SHIFT) KEY_MAP_WIN (Shift, VK_SHIFT)
@ -161,11 +146,8 @@ KEY_MAP_COCOA (Shift, kVK_RightShift)
KEY_MAP_GTK (Shift, GDK_Shift_L) KEY_MAP_GTK (Shift, GDK_Shift_L)
KEY_MAP_GTK (Shift, GDK_Shift_R) KEY_MAP_GTK (Shift, GDK_Shift_R)
KEY_MAP_GTK (Shift, GDK_Shift_Lock) // Let's treat as Shift key (bug 769159) KEY_MAP_GTK (Shift, GDK_Shift_Lock) // Let's treat as Shift key (bug 769159)
KEY_MAP_ANDROID (Shift, AKEYCODE_SHIFT_LEFT)
KEY_MAP_ANDROID (Shift, AKEYCODE_SHIFT_RIGHT)
// Symbol // Symbol
KEY_MAP_ANDROID (Symbol, AKEYCODE_SYM)
/****************************************************************************** /******************************************************************************
* Whitespace Keys * Whitespace Keys
@ -179,8 +161,6 @@ KEY_MAP_GTK (Enter, GDK_Return)
KEY_MAP_GTK (Enter, GDK_KP_Enter) KEY_MAP_GTK (Enter, GDK_KP_Enter)
KEY_MAP_GTK (Enter, GDK_ISO_Enter) KEY_MAP_GTK (Enter, GDK_ISO_Enter)
KEY_MAP_GTK (Enter, GDK_3270_Enter) KEY_MAP_GTK (Enter, GDK_3270_Enter)
KEY_MAP_ANDROID (Enter, AKEYCODE_ENTER)
KEY_MAP_ANDROID (Enter, AKEYCODE_NUMPAD_ENTER)
// Tab // Tab
KEY_MAP_WIN (Tab, VK_TAB) KEY_MAP_WIN (Tab, VK_TAB)
@ -188,7 +168,6 @@ KEY_MAP_COCOA (Tab, kVK_Tab)
KEY_MAP_GTK (Tab, GDK_Tab) KEY_MAP_GTK (Tab, GDK_Tab)
KEY_MAP_GTK (Tab, GDK_ISO_Left_Tab) // Shift+Tab KEY_MAP_GTK (Tab, GDK_ISO_Left_Tab) // Shift+Tab
KEY_MAP_GTK (Tab, GDK_KP_Tab) KEY_MAP_GTK (Tab, GDK_KP_Tab)
KEY_MAP_ANDROID (Tab, AKEYCODE_TAB)
/****************************************************************************** /******************************************************************************
* Navigation Keys * Navigation Keys
@ -198,56 +177,48 @@ KEY_MAP_WIN (ArrowDown, VK_DOWN)
KEY_MAP_COCOA (ArrowDown, kVK_DownArrow) KEY_MAP_COCOA (ArrowDown, kVK_DownArrow)
KEY_MAP_GTK (ArrowDown, GDK_Down) KEY_MAP_GTK (ArrowDown, GDK_Down)
KEY_MAP_GTK (ArrowDown, GDK_KP_Down) KEY_MAP_GTK (ArrowDown, GDK_KP_Down)
KEY_MAP_ANDROID (ArrowDown, AKEYCODE_DPAD_DOWN)
// ArrowLeft // ArrowLeft
KEY_MAP_WIN (ArrowLeft, VK_LEFT) KEY_MAP_WIN (ArrowLeft, VK_LEFT)
KEY_MAP_COCOA (ArrowLeft, kVK_LeftArrow) KEY_MAP_COCOA (ArrowLeft, kVK_LeftArrow)
KEY_MAP_GTK (ArrowLeft, GDK_Left) KEY_MAP_GTK (ArrowLeft, GDK_Left)
KEY_MAP_GTK (ArrowLeft, GDK_KP_Left) KEY_MAP_GTK (ArrowLeft, GDK_KP_Left)
KEY_MAP_ANDROID (ArrowLeft, AKEYCODE_DPAD_LEFT)
// ArrowRight // ArrowRight
KEY_MAP_WIN (ArrowRight, VK_RIGHT) KEY_MAP_WIN (ArrowRight, VK_RIGHT)
KEY_MAP_COCOA (ArrowRight, kVK_RightArrow) KEY_MAP_COCOA (ArrowRight, kVK_RightArrow)
KEY_MAP_GTK (ArrowRight, GDK_Right) KEY_MAP_GTK (ArrowRight, GDK_Right)
KEY_MAP_GTK (ArrowRight, GDK_KP_Right) KEY_MAP_GTK (ArrowRight, GDK_KP_Right)
KEY_MAP_ANDROID (ArrowRight, AKEYCODE_DPAD_RIGHT)
// ArrowUp // ArrowUp
KEY_MAP_WIN (ArrowUp, VK_UP) KEY_MAP_WIN (ArrowUp, VK_UP)
KEY_MAP_COCOA (ArrowUp, kVK_UpArrow) KEY_MAP_COCOA (ArrowUp, kVK_UpArrow)
KEY_MAP_GTK (ArrowUp, GDK_Up) KEY_MAP_GTK (ArrowUp, GDK_Up)
KEY_MAP_GTK (ArrowUp, GDK_KP_Up) KEY_MAP_GTK (ArrowUp, GDK_KP_Up)
KEY_MAP_ANDROID (ArrowUp, AKEYCODE_DPAD_UP)
// End // End
KEY_MAP_WIN (End, VK_END) KEY_MAP_WIN (End, VK_END)
KEY_MAP_COCOA (End, kVK_End) KEY_MAP_COCOA (End, kVK_End)
KEY_MAP_GTK (End, GDK_End) KEY_MAP_GTK (End, GDK_End)
KEY_MAP_GTK (End, GDK_KP_End) KEY_MAP_GTK (End, GDK_KP_End)
KEY_MAP_ANDROID (End, AKEYCODE_MOVE_END)
// Home // Home
KEY_MAP_WIN (Home, VK_HOME) KEY_MAP_WIN (Home, VK_HOME)
KEY_MAP_COCOA (Home, kVK_Home) KEY_MAP_COCOA (Home, kVK_Home)
KEY_MAP_GTK (Home, GDK_Home) KEY_MAP_GTK (Home, GDK_Home)
KEY_MAP_GTK (Home, GDK_KP_Home) KEY_MAP_GTK (Home, GDK_KP_Home)
KEY_MAP_ANDROID (Home, AKEYCODE_MOVE_HOME)
// PageDown // PageDown
KEY_MAP_WIN (PageDown, VK_NEXT) KEY_MAP_WIN (PageDown, VK_NEXT)
KEY_MAP_COCOA (PageDown, kVK_PageDown) KEY_MAP_COCOA (PageDown, kVK_PageDown)
KEY_MAP_GTK (PageDown, GDK_Page_Down /* same as GDK_Next */) KEY_MAP_GTK (PageDown, GDK_Page_Down /* same as GDK_Next */)
KEY_MAP_GTK (PageDown, GDK_KP_Page_Down /* same as GDK_KP_Next */) KEY_MAP_GTK (PageDown, GDK_KP_Page_Down /* same as GDK_KP_Next */)
KEY_MAP_ANDROID (PageDown, AKEYCODE_PAGE_DOWN)
// PageUp // PageUp
KEY_MAP_WIN (PageUp, VK_PRIOR) KEY_MAP_WIN (PageUp, VK_PRIOR)
KEY_MAP_COCOA (PageUp, kVK_PageUp) KEY_MAP_COCOA (PageUp, kVK_PageUp)
KEY_MAP_GTK (PageUp, GDK_Page_Up /* same as GDK_Prior */) KEY_MAP_GTK (PageUp, GDK_Page_Up /* same as GDK_Prior */)
KEY_MAP_GTK (PageUp, GDK_KP_Page_Up /* same as GDK_KP_Prior */) KEY_MAP_GTK (PageUp, GDK_KP_Page_Up /* same as GDK_KP_Prior */)
KEY_MAP_ANDROID (PageUp, AKEYCODE_PAGE_UP)
/****************************************************************************** /******************************************************************************
* Editing Keys * Editing Keys
@ -256,14 +227,12 @@ KEY_MAP_ANDROID (PageUp, AKEYCODE_PAGE_UP)
KEY_MAP_WIN (Backspace, VK_BACK) KEY_MAP_WIN (Backspace, VK_BACK)
KEY_MAP_COCOA (Backspace, kVK_PC_Backspace) KEY_MAP_COCOA (Backspace, kVK_PC_Backspace)
KEY_MAP_GTK (Backspace, GDK_BackSpace) KEY_MAP_GTK (Backspace, GDK_BackSpace)
KEY_MAP_ANDROID (Backspace, AKEYCODE_DEL)
// Clear // Clear
KEY_MAP_WIN (Clear, VK_CLEAR) KEY_MAP_WIN (Clear, VK_CLEAR)
KEY_MAP_WIN (Clear, VK_OEM_CLEAR) KEY_MAP_WIN (Clear, VK_OEM_CLEAR)
KEY_MAP_COCOA (Clear, kVK_ANSI_KeypadClear) KEY_MAP_COCOA (Clear, kVK_ANSI_KeypadClear)
KEY_MAP_GTK (Clear, GDK_Clear) KEY_MAP_GTK (Clear, GDK_Clear)
KEY_MAP_ANDROID (Clear, AKEYCODE_CLEAR)
// Copy // Copy
KEY_MAP_WIN_CMD (Copy, APPCOMMAND_COPY) KEY_MAP_WIN_CMD (Copy, APPCOMMAND_COPY)
@ -282,7 +251,6 @@ KEY_MAP_WIN (Delete, VK_DELETE)
KEY_MAP_COCOA (Delete, kVK_PC_Delete) KEY_MAP_COCOA (Delete, kVK_PC_Delete)
KEY_MAP_GTK (Delete, GDK_Delete) KEY_MAP_GTK (Delete, GDK_Delete)
KEY_MAP_GTK (Delete, GDK_KP_Delete) KEY_MAP_GTK (Delete, GDK_KP_Delete)
KEY_MAP_ANDROID (Delete, AKEYCODE_FORWARD_DEL)
// EraseEof // EraseEof
KEY_MAP_WIN (EraseEof, VK_EREOF) KEY_MAP_WIN (EraseEof, VK_EREOF)
@ -296,7 +264,6 @@ KEY_MAP_GTK (ExSel, GDK_3270_ExSelect) // legacy IBM keyboard layout
KEY_MAP_WIN (Insert, VK_INSERT) KEY_MAP_WIN (Insert, VK_INSERT)
KEY_MAP_GTK (Insert, GDK_Insert) KEY_MAP_GTK (Insert, GDK_Insert)
KEY_MAP_GTK (Insert, GDK_KP_Insert) KEY_MAP_GTK (Insert, GDK_KP_Insert)
KEY_MAP_ANDROID (Insert, AKEYCODE_INSERT)
// Paste // Paste
KEY_MAP_WIN_CMD (Paste, APPCOMMAND_PASTE) KEY_MAP_WIN_CMD (Paste, APPCOMMAND_PASTE)
@ -315,7 +282,6 @@ KEY_MAP_GTK (Undo, GDK_Undo)
******************************************************************************/ ******************************************************************************/
// Accept // Accept
KEY_MAP_WIN (Accept, VK_ACCEPT) KEY_MAP_WIN (Accept, VK_ACCEPT)
KEY_MAP_ANDROID (Accept, AKEYCODE_DPAD_CENTER)
// Attn // Attn
KEY_MAP_WIN_OTH (Attn, VK_ATTN) // not valid with Japanese keyboard layout KEY_MAP_WIN_OTH (Attn, VK_ATTN) // not valid with Japanese keyboard layout
@ -329,13 +295,11 @@ KEY_MAP_GTK (Cancel, GDK_Cancel)
KEY_MAP_WIN (ContextMenu, VK_APPS) KEY_MAP_WIN (ContextMenu, VK_APPS)
KEY_MAP_COCOA (ContextMenu, kVK_PC_ContextMenu) KEY_MAP_COCOA (ContextMenu, kVK_PC_ContextMenu)
KEY_MAP_GTK (ContextMenu, GDK_Menu) KEY_MAP_GTK (ContextMenu, GDK_Menu)
KEY_MAP_ANDROID (ContextMenu, AKEYCODE_MENU)
// Escape // Escape
KEY_MAP_WIN (Escape, VK_ESCAPE) KEY_MAP_WIN (Escape, VK_ESCAPE)
KEY_MAP_COCOA (Escape, kVK_Escape) KEY_MAP_COCOA (Escape, kVK_Escape)
KEY_MAP_GTK (Escape, GDK_Escape) KEY_MAP_GTK (Escape, GDK_Escape)
KEY_MAP_ANDROID (Escape, AKEYCODE_ESCAPE)
// Execute // Execute
KEY_MAP_WIN (Execute, VK_EXECUTE) KEY_MAP_WIN (Execute, VK_EXECUTE)
@ -350,14 +314,12 @@ KEY_MAP_WIN (Help, VK_HELP)
KEY_MAP_WIN_CMD (Help, APPCOMMAND_HELP) KEY_MAP_WIN_CMD (Help, APPCOMMAND_HELP)
KEY_MAP_COCOA (Help, kVK_Help) KEY_MAP_COCOA (Help, kVK_Help)
KEY_MAP_GTK (Help, GDK_Help) KEY_MAP_GTK (Help, GDK_Help)
KEY_MAP_ANDROID (Help, AKEYCODE_ASSIST)
// Pause // Pause
KEY_MAP_WIN (Pause, VK_PAUSE) KEY_MAP_WIN (Pause, VK_PAUSE)
KEY_MAP_GTK (Pause, GDK_Pause) KEY_MAP_GTK (Pause, GDK_Pause)
// Break is typically mapped to Alt+Pause or Ctrl+Pause on GTK. // Break is typically mapped to Alt+Pause or Ctrl+Pause on GTK.
KEY_MAP_GTK (Pause, GDK_Break) KEY_MAP_GTK (Pause, GDK_Break)
KEY_MAP_ANDROID (Pause, AKEYCODE_BREAK)
// Play // Play
KEY_MAP_WIN (Play, VK_PLAY) KEY_MAP_WIN (Play, VK_PLAY)
@ -369,11 +331,9 @@ KEY_MAP_GTK (Select, GDK_Select)
// ZoomIn // ZoomIn
KEY_MAP_GTK (ZoomIn, GDK_ZoomIn) KEY_MAP_GTK (ZoomIn, GDK_ZoomIn)
KEY_MAP_ANDROID (ZoomIn, AKEYCODE_ZOOM_IN)
// ZoomOut // ZoomOut
KEY_MAP_GTK (ZoomOut, GDK_ZoomOut) KEY_MAP_GTK (ZoomOut, GDK_ZoomOut)
KEY_MAP_ANDROID (ZoomOut, AKEYCODE_ZOOM_OUT)
/****************************************************************************** /******************************************************************************
* Device Keys * Device Keys
@ -386,13 +346,11 @@ KEY_MAP_GTK (BrightnessUp, GDK_MonBrightnessUp)
// Eject // Eject
KEY_MAP_GTK (Eject, GDK_Eject) KEY_MAP_GTK (Eject, GDK_Eject)
KEY_MAP_ANDROID (Eject, AKEYCODE_MEDIA_EJECT)
// LogOff // LogOff
KEY_MAP_GTK (LogOff, GDK_LogOff) KEY_MAP_GTK (LogOff, GDK_LogOff)
// Power // Power
KEY_MAP_ANDROID (Power, AKEYCODE_POWER)
// PowerOff // PowerOff
KEY_MAP_GTK (PowerOff, GDK_PowerDown) KEY_MAP_GTK (PowerOff, GDK_PowerDown)
@ -403,7 +361,6 @@ KEY_MAP_WIN (PrintScreen, VK_SNAPSHOT)
KEY_MAP_GTK (PrintScreen, GDK_3270_PrintScreen) KEY_MAP_GTK (PrintScreen, GDK_3270_PrintScreen)
KEY_MAP_GTK (PrintScreen, GDK_Print) KEY_MAP_GTK (PrintScreen, GDK_Print)
KEY_MAP_GTK (PrintScreen, GDK_Sys_Req) KEY_MAP_GTK (PrintScreen, GDK_Sys_Req)
KEY_MAP_ANDROID (PrintScreen, AKEYCODE_SYSRQ)
// Hibernate // Hibernate
KEY_MAP_GTK (Hibernate, GDK_Hibernate) KEY_MAP_GTK (Hibernate, GDK_Hibernate)
@ -437,7 +394,6 @@ KEY_MAP_GTK (Compose, GDK_Multi_key) // "Multi Key" is "Compose key" on X
// Convert // Convert
KEY_MAP_WIN (Convert, VK_CONVERT) KEY_MAP_WIN (Convert, VK_CONVERT)
KEY_MAP_GTK (Convert, GDK_Henkan) KEY_MAP_GTK (Convert, GDK_Henkan)
KEY_MAP_ANDROID (Convert, AKEYCODE_HENKAN)
// Dead // Dead
KEY_MAP_GTK (Dead, GDK_dead_grave) KEY_MAP_GTK (Dead, GDK_dead_grave)
@ -497,19 +453,16 @@ KEY_MAP_GTK (GroupLast, GDK_ISO_Last_Group)
// GroupNext // GroupNext
KEY_MAP_GTK (GroupNext, GDK_ISO_Next_Group) KEY_MAP_GTK (GroupNext, GDK_ISO_Next_Group)
KEY_MAP_ANDROID (GroupNext, AKEYCODE_LANGUAGE_SWITCH)
// GroupPrevious // GroupPrevious
KEY_MAP_GTK (GroupPrevious, GDK_ISO_Prev_Group) KEY_MAP_GTK (GroupPrevious, GDK_ISO_Prev_Group)
// ModeChange // ModeChange
KEY_MAP_WIN (ModeChange, VK_MODECHANGE) KEY_MAP_WIN (ModeChange, VK_MODECHANGE)
KEY_MAP_ANDROID (ModeChange, AKEYCODE_SWITCH_CHARSET)
// NonConvert // NonConvert
KEY_MAP_WIN (NonConvert, VK_NONCONVERT) KEY_MAP_WIN (NonConvert, VK_NONCONVERT)
KEY_MAP_GTK (NonConvert, GDK_Muhenkan) KEY_MAP_GTK (NonConvert, GDK_Muhenkan)
KEY_MAP_ANDROID (NonConvert, AKEYCODE_MUHENKAN)
// PreviousCandidate // PreviousCandidate
KEY_MAP_GTK (PreviousCandidate, GDK_PreviousCandidate) // OADG 109, Mae Koho KEY_MAP_GTK (PreviousCandidate, GDK_PreviousCandidate) // OADG 109, Mae Koho
@ -534,7 +487,6 @@ KEY_MAP_WIN (JunjaMode, VK_JUNJA)
******************************************************************************/ ******************************************************************************/
// Eisu // Eisu
KEY_MAP_COCOA (Eisu, kVK_JIS_Eisu) KEY_MAP_COCOA (Eisu, kVK_JIS_Eisu)
KEY_MAP_ANDROID (Eisu, AKEYCODE_EISU)
// Hankaku // Hankaku
KEY_MAP_WIN_JPN (Hankaku, VK_OEM_AUTO) KEY_MAP_WIN_JPN (Hankaku, VK_OEM_AUTO)
@ -546,7 +498,6 @@ KEY_MAP_GTK (Hiragana, GDK_Hiragana)
// HiraganaKatakana // HiraganaKatakana
KEY_MAP_GTK (HiraganaKatakana, GDK_Hiragana_Katakana) KEY_MAP_GTK (HiraganaKatakana, GDK_Hiragana_Katakana)
KEY_MAP_ANDROID (HiraganaKatakana, AKEYCODE_KATAKANA_HIRAGANA)
// KanaMode // KanaMode
// VK_KANA is never used with modern Japanese keyboard, however, IE maps it to // VK_KANA is never used with modern Japanese keyboard, however, IE maps it to
@ -560,8 +511,6 @@ KEY_MAP_GTK (KanaMode, GDK_Kana_Shift)
KEY_MAP_WIN_JPN (KanjiMode, VK_KANJI /* same as VK_HANJA */) KEY_MAP_WIN_JPN (KanjiMode, VK_KANJI /* same as VK_HANJA */)
KEY_MAP_COCOA (KanjiMode, kVK_JIS_Kana) // Kana key opens IME KEY_MAP_COCOA (KanjiMode, kVK_JIS_Kana) // Kana key opens IME
KEY_MAP_GTK (KanjiMode, GDK_Kanji) // Typically, Alt + Hankaku/Zenkaku key KEY_MAP_GTK (KanjiMode, GDK_Kanji) // Typically, Alt + Hankaku/Zenkaku key
// Assuming that KANA key of Android is the Kana key on Mac keyboard.
KEY_MAP_ANDROID (KanjiMode, AKEYCODE_KANA)
// Katakana // Katakana
KEY_MAP_WIN_JPN (Katakana, VK_OEM_FINISH) KEY_MAP_WIN_JPN (Katakana, VK_OEM_FINISH)
@ -577,7 +526,6 @@ KEY_MAP_GTK (Zenkaku, GDK_Zenkaku)
// ZenkakuHankaku // ZenkakuHankaku
KEY_MAP_GTK (ZenkakuHankaku, GDK_Zenkaku_Hankaku) KEY_MAP_GTK (ZenkakuHankaku, GDK_Zenkaku_Hankaku)
KEY_MAP_ANDROID (ZenkakuHankaku, AKEYCODE_ZENKAKU_HANKAKU)
/****************************************************************************** /******************************************************************************
* General-Purpose Function Keys * General-Purpose Function Keys
@ -587,76 +535,64 @@ KEY_MAP_WIN (F1, VK_F1)
KEY_MAP_COCOA (F1, kVK_F1) KEY_MAP_COCOA (F1, kVK_F1)
KEY_MAP_GTK (F1, GDK_F1) KEY_MAP_GTK (F1, GDK_F1)
KEY_MAP_GTK (F1, GDK_KP_F1) KEY_MAP_GTK (F1, GDK_KP_F1)
KEY_MAP_ANDROID (F1, AKEYCODE_F1)
// F2 // F2
KEY_MAP_WIN (F2, VK_F2) KEY_MAP_WIN (F2, VK_F2)
KEY_MAP_COCOA (F2, kVK_F2) KEY_MAP_COCOA (F2, kVK_F2)
KEY_MAP_GTK (F2, GDK_F2) KEY_MAP_GTK (F2, GDK_F2)
KEY_MAP_GTK (F2, GDK_KP_F2) KEY_MAP_GTK (F2, GDK_KP_F2)
KEY_MAP_ANDROID (F2, AKEYCODE_F2)
// F3 // F3
KEY_MAP_WIN (F3, VK_F3) KEY_MAP_WIN (F3, VK_F3)
KEY_MAP_COCOA (F3, kVK_F3) KEY_MAP_COCOA (F3, kVK_F3)
KEY_MAP_GTK (F3, GDK_F3) KEY_MAP_GTK (F3, GDK_F3)
KEY_MAP_GTK (F3, GDK_KP_F3) KEY_MAP_GTK (F3, GDK_KP_F3)
KEY_MAP_ANDROID (F3, AKEYCODE_F3)
// F4 // F4
KEY_MAP_WIN (F4, VK_F4) KEY_MAP_WIN (F4, VK_F4)
KEY_MAP_COCOA (F4, kVK_F4) KEY_MAP_COCOA (F4, kVK_F4)
KEY_MAP_GTK (F4, GDK_F4) KEY_MAP_GTK (F4, GDK_F4)
KEY_MAP_GTK (F4, GDK_KP_F4) KEY_MAP_GTK (F4, GDK_KP_F4)
KEY_MAP_ANDROID (F4, AKEYCODE_F4)
// F5 // F5
KEY_MAP_WIN (F5, VK_F5) KEY_MAP_WIN (F5, VK_F5)
KEY_MAP_COCOA (F5, kVK_F5) KEY_MAP_COCOA (F5, kVK_F5)
KEY_MAP_GTK (F5, GDK_F5) KEY_MAP_GTK (F5, GDK_F5)
KEY_MAP_ANDROID (F5, AKEYCODE_F5)
// F6 // F6
KEY_MAP_WIN (F6, VK_F6) KEY_MAP_WIN (F6, VK_F6)
KEY_MAP_COCOA (F6, kVK_F6) KEY_MAP_COCOA (F6, kVK_F6)
KEY_MAP_GTK (F6, GDK_F6) KEY_MAP_GTK (F6, GDK_F6)
KEY_MAP_ANDROID (F6, AKEYCODE_F6)
// F7 // F7
KEY_MAP_WIN (F7, VK_F7) KEY_MAP_WIN (F7, VK_F7)
KEY_MAP_COCOA (F7, kVK_F7) KEY_MAP_COCOA (F7, kVK_F7)
KEY_MAP_GTK (F7, GDK_F7) KEY_MAP_GTK (F7, GDK_F7)
KEY_MAP_ANDROID (F7, AKEYCODE_F7)
// F8 // F8
KEY_MAP_WIN (F8, VK_F8) KEY_MAP_WIN (F8, VK_F8)
KEY_MAP_COCOA (F8, kVK_F8) KEY_MAP_COCOA (F8, kVK_F8)
KEY_MAP_GTK (F8, GDK_F8) KEY_MAP_GTK (F8, GDK_F8)
KEY_MAP_ANDROID (F8, AKEYCODE_F8)
// F9 // F9
KEY_MAP_WIN (F9, VK_F9) KEY_MAP_WIN (F9, VK_F9)
KEY_MAP_COCOA (F9, kVK_F9) KEY_MAP_COCOA (F9, kVK_F9)
KEY_MAP_GTK (F9, GDK_F9) KEY_MAP_GTK (F9, GDK_F9)
KEY_MAP_ANDROID (F9, AKEYCODE_F9)
// F10 // F10
KEY_MAP_WIN (F10, VK_F10) KEY_MAP_WIN (F10, VK_F10)
KEY_MAP_COCOA (F10, kVK_F10) KEY_MAP_COCOA (F10, kVK_F10)
KEY_MAP_GTK (F10, GDK_F10) KEY_MAP_GTK (F10, GDK_F10)
KEY_MAP_ANDROID (F10, AKEYCODE_F10)
// F11 // F11
KEY_MAP_WIN (F11, VK_F11) KEY_MAP_WIN (F11, VK_F11)
KEY_MAP_COCOA (F11, kVK_F11) KEY_MAP_COCOA (F11, kVK_F11)
KEY_MAP_GTK (F11, GDK_F11 /* same as GDK_L1 */) KEY_MAP_GTK (F11, GDK_F11 /* same as GDK_L1 */)
KEY_MAP_ANDROID (F11, AKEYCODE_F11)
// F12 // F12
KEY_MAP_WIN (F12, VK_F12) KEY_MAP_WIN (F12, VK_F12)
KEY_MAP_COCOA (F12, kVK_F12) KEY_MAP_COCOA (F12, kVK_F12)
KEY_MAP_GTK (F12, GDK_F12 /* same as GDK_L2 */) KEY_MAP_GTK (F12, GDK_F12 /* same as GDK_L2 */)
KEY_MAP_ANDROID (F12, AKEYCODE_F12)
// F13 // F13
KEY_MAP_WIN (F13, VK_F13) KEY_MAP_WIN (F13, VK_F13)
@ -751,11 +687,9 @@ KEY_MAP_GTK (F35, GDK_F35 /* same as GDK_R15 */)
******************************************************************************/ ******************************************************************************/
// ChannelDown // ChannelDown
KEY_MAP_WIN_CMD (ChannelDown, APPCOMMAND_MEDIA_CHANNEL_DOWN) KEY_MAP_WIN_CMD (ChannelDown, APPCOMMAND_MEDIA_CHANNEL_DOWN)
KEY_MAP_ANDROID (ChannelDown, AKEYCODE_CHANNEL_DOWN)
// ChannelUp // ChannelUp
KEY_MAP_WIN_CMD (ChannelUp, APPCOMMAND_MEDIA_CHANNEL_UP) KEY_MAP_WIN_CMD (ChannelUp, APPCOMMAND_MEDIA_CHANNEL_UP)
KEY_MAP_ANDROID (ChannelUp, AKEYCODE_CHANNEL_UP)
// Close // Close
// NOTE: This is not a key to close disk tray, this is a key to close document // NOTE: This is not a key to close disk tray, this is a key to close document
@ -778,45 +712,37 @@ KEY_MAP_GTK (MailSend, GDK_Send)
// MediaPause // MediaPause
KEY_MAP_WIN_CMD (MediaPause, APPCOMMAND_MEDIA_PAUSE) KEY_MAP_WIN_CMD (MediaPause, APPCOMMAND_MEDIA_PAUSE)
KEY_MAP_GTK (MediaPause, GDK_AudioPause) KEY_MAP_GTK (MediaPause, GDK_AudioPause)
KEY_MAP_ANDROID (MediaPause, AKEYCODE_MEDIA_PAUSE)
// MediaPlay // MediaPlay
KEY_MAP_WIN_CMD (MediaPlay, APPCOMMAND_MEDIA_PLAY) KEY_MAP_WIN_CMD (MediaPlay, APPCOMMAND_MEDIA_PLAY)
KEY_MAP_GTK (MediaPlay, GDK_AudioPlay) KEY_MAP_GTK (MediaPlay, GDK_AudioPlay)
KEY_MAP_ANDROID (MediaPlay, AKEYCODE_MEDIA_PLAY)
// MediaPlayPause // MediaPlayPause
KEY_MAP_WIN (MediaPlayPause, VK_MEDIA_PLAY_PAUSE) KEY_MAP_WIN (MediaPlayPause, VK_MEDIA_PLAY_PAUSE)
KEY_MAP_WIN_CMD (MediaPlayPause, APPCOMMAND_MEDIA_PLAY_PAUSE) KEY_MAP_WIN_CMD (MediaPlayPause, APPCOMMAND_MEDIA_PLAY_PAUSE)
KEY_MAP_ANDROID (MediaPlayPause, AKEYCODE_MEDIA_PLAY_PAUSE)
// MediaRecord // MediaRecord
KEY_MAP_WIN_CMD (MediaRecord, APPCOMMAND_MEDIA_RECORD) KEY_MAP_WIN_CMD (MediaRecord, APPCOMMAND_MEDIA_RECORD)
KEY_MAP_GTK (MediaRecord, GDK_AudioRecord) KEY_MAP_GTK (MediaRecord, GDK_AudioRecord)
KEY_MAP_ANDROID (MediaRecord, AKEYCODE_MEDIA_RECORD)
// MediaRewind // MediaRewind
KEY_MAP_WIN_CMD (MediaRewind, APPCOMMAND_MEDIA_REWIND) KEY_MAP_WIN_CMD (MediaRewind, APPCOMMAND_MEDIA_REWIND)
KEY_MAP_GTK (MediaRewind, GDK_AudioRewind) KEY_MAP_GTK (MediaRewind, GDK_AudioRewind)
KEY_MAP_ANDROID (MediaRewind, AKEYCODE_MEDIA_REWIND)
// MediaStop // MediaStop
KEY_MAP_WIN (MediaStop, VK_MEDIA_STOP) KEY_MAP_WIN (MediaStop, VK_MEDIA_STOP)
KEY_MAP_WIN_CMD (MediaStop, APPCOMMAND_MEDIA_STOP) KEY_MAP_WIN_CMD (MediaStop, APPCOMMAND_MEDIA_STOP)
KEY_MAP_GTK (MediaStop, GDK_AudioStop) KEY_MAP_GTK (MediaStop, GDK_AudioStop)
KEY_MAP_ANDROID (MediaStop, AKEYCODE_MEDIA_STOP)
// MediaTrackNext // MediaTrackNext
KEY_MAP_WIN (MediaTrackNext, VK_MEDIA_NEXT_TRACK) KEY_MAP_WIN (MediaTrackNext, VK_MEDIA_NEXT_TRACK)
KEY_MAP_WIN_CMD (MediaTrackNext, APPCOMMAND_MEDIA_NEXTTRACK) KEY_MAP_WIN_CMD (MediaTrackNext, APPCOMMAND_MEDIA_NEXTTRACK)
KEY_MAP_GTK (MediaTrackNext, GDK_AudioNext) KEY_MAP_GTK (MediaTrackNext, GDK_AudioNext)
KEY_MAP_ANDROID (MediaTrackNext, AKEYCODE_MEDIA_NEXT)
// MediaTrackPrevious // MediaTrackPrevious
KEY_MAP_WIN (MediaTrackPrevious, VK_MEDIA_PREV_TRACK) KEY_MAP_WIN (MediaTrackPrevious, VK_MEDIA_PREV_TRACK)
KEY_MAP_WIN_CMD (MediaTrackPrevious, APPCOMMAND_MEDIA_PREVIOUSTRACK) KEY_MAP_WIN_CMD (MediaTrackPrevious, APPCOMMAND_MEDIA_PREVIOUSTRACK)
KEY_MAP_GTK (MediaTrackPrevious, GDK_AudioPrev) KEY_MAP_GTK (MediaTrackPrevious, GDK_AudioPrev)
KEY_MAP_ANDROID (MediaTrackPrevious, AKEYCODE_MEDIA_PREVIOUS)
// New // New
KEY_MAP_WIN_CMD (New, APPCOMMAND_NEW) KEY_MAP_WIN_CMD (New, APPCOMMAND_NEW)
@ -851,38 +777,32 @@ KEY_MAP_WIN (AudioVolumeDown, VK_VOLUME_DOWN)
KEY_MAP_WIN_CMD (AudioVolumeDown, APPCOMMAND_VOLUME_DOWN) KEY_MAP_WIN_CMD (AudioVolumeDown, APPCOMMAND_VOLUME_DOWN)
KEY_MAP_COCOA (AudioVolumeDown, kVK_VolumeDown) KEY_MAP_COCOA (AudioVolumeDown, kVK_VolumeDown)
KEY_MAP_GTK (AudioVolumeDown, GDK_AudioLowerVolume) KEY_MAP_GTK (AudioVolumeDown, GDK_AudioLowerVolume)
KEY_MAP_ANDROID (AudioVolumeDown, AKEYCODE_VOLUME_DOWN)
// AudioVolumeUp // AudioVolumeUp
KEY_MAP_WIN (AudioVolumeUp, VK_VOLUME_UP) KEY_MAP_WIN (AudioVolumeUp, VK_VOLUME_UP)
KEY_MAP_WIN_CMD (AudioVolumeUp, APPCOMMAND_VOLUME_UP) KEY_MAP_WIN_CMD (AudioVolumeUp, APPCOMMAND_VOLUME_UP)
KEY_MAP_COCOA (AudioVolumeUp, kVK_VolumeUp) KEY_MAP_COCOA (AudioVolumeUp, kVK_VolumeUp)
KEY_MAP_GTK (AudioVolumeUp, GDK_AudioRaiseVolume) KEY_MAP_GTK (AudioVolumeUp, GDK_AudioRaiseVolume)
KEY_MAP_ANDROID (AudioVolumeUp, AKEYCODE_VOLUME_UP)
// AudioVolumeMute // AudioVolumeMute
KEY_MAP_WIN (AudioVolumeMute, VK_VOLUME_MUTE) KEY_MAP_WIN (AudioVolumeMute, VK_VOLUME_MUTE)
KEY_MAP_WIN_CMD (AudioVolumeMute, APPCOMMAND_VOLUME_MUTE) KEY_MAP_WIN_CMD (AudioVolumeMute, APPCOMMAND_VOLUME_MUTE)
KEY_MAP_COCOA (AudioVolumeMute, kVK_Mute) KEY_MAP_COCOA (AudioVolumeMute, kVK_Mute)
KEY_MAP_GTK (AudioVolumeMute, GDK_AudioMute) KEY_MAP_GTK (AudioVolumeMute, GDK_AudioMute)
KEY_MAP_ANDROID (AudioVolumeMute, AKEYCODE_VOLUME_MUTE)
/****************************************************************************** /******************************************************************************
* Application Keys * Application Keys
******************************************************************************/ ******************************************************************************/
// LaunchCalculator // LaunchCalculator
KEY_MAP_GTK (LaunchCalculator, GDK_Calculator) KEY_MAP_GTK (LaunchCalculator, GDK_Calculator)
KEY_MAP_ANDROID (LaunchCalculator, AKEYCODE_CALCULATOR)
// LaunchCalendar // LaunchCalendar
KEY_MAP_GTK (LaunchCalendar, GDK_Calendar) KEY_MAP_GTK (LaunchCalendar, GDK_Calendar)
KEY_MAP_ANDROID (LaunchCalendar, AKEYCODE_CALENDAR)
// LaunchMail // LaunchMail
KEY_MAP_WIN (LaunchMail, VK_LAUNCH_MAIL) KEY_MAP_WIN (LaunchMail, VK_LAUNCH_MAIL)
KEY_MAP_WIN_CMD (LaunchMail, APPCOMMAND_LAUNCH_MAIL) KEY_MAP_WIN_CMD (LaunchMail, APPCOMMAND_LAUNCH_MAIL)
KEY_MAP_GTK (LaunchMail, GDK_Mail) KEY_MAP_GTK (LaunchMail, GDK_Mail)
KEY_MAP_ANDROID (LaunchMail, AKEYCODE_ENVELOPE)
// LaunchMediaPlayer // LaunchMediaPlayer
KEY_MAP_WIN (LaunchMediaPlayer, VK_LAUNCH_MEDIA_SELECT) KEY_MAP_WIN (LaunchMediaPlayer, VK_LAUNCH_MEDIA_SELECT)
@ -895,7 +815,6 @@ KEY_MAP_GTK (LaunchMediaPlayer, GDK_AudioMedia)
// LaunchMusicPlayer // LaunchMusicPlayer
KEY_MAP_GTK (LaunchMusicPlayer, GDK_Music) KEY_MAP_GTK (LaunchMusicPlayer, GDK_Music)
KEY_MAP_ANDROID (LaunchMusicPlayer, AKEYCODE_MUSIC)
// LaunchMyComputer // LaunchMyComputer
KEY_MAP_GTK (LaunchMyComputer, GDK_MyComputer) KEY_MAP_GTK (LaunchMyComputer, GDK_MyComputer)
@ -909,7 +828,6 @@ KEY_MAP_GTK (LaunchSpreadsheet, GDK_Excel)
// LaunchWebBrowser // LaunchWebBrowser
KEY_MAP_GTK (LaunchWebBrowser, GDK_WWW) KEY_MAP_GTK (LaunchWebBrowser, GDK_WWW)
KEY_MAP_ANDROID (LaunchWebBrowser, AKEYCODE_EXPLORER)
// LaunchWebCam // LaunchWebCam
KEY_MAP_GTK (LaunchWebCam, GDK_WebCam) KEY_MAP_GTK (LaunchWebCam, GDK_WebCam)
@ -980,18 +898,15 @@ KEY_MAP_GTK (LaunchApplication16, GDK_LaunchF)
KEY_MAP_WIN (BrowserBack, VK_BROWSER_BACK) KEY_MAP_WIN (BrowserBack, VK_BROWSER_BACK)
KEY_MAP_WIN_CMD (BrowserBack, APPCOMMAND_BROWSER_BACKWARD) KEY_MAP_WIN_CMD (BrowserBack, APPCOMMAND_BROWSER_BACKWARD)
KEY_MAP_GTK (BrowserBack, GDK_Back) KEY_MAP_GTK (BrowserBack, GDK_Back)
KEY_MAP_ANDROID (BrowserBack, AKEYCODE_BACK)
// BrowserFavorites // BrowserFavorites
KEY_MAP_WIN (BrowserFavorites, VK_BROWSER_FAVORITES) KEY_MAP_WIN (BrowserFavorites, VK_BROWSER_FAVORITES)
KEY_MAP_WIN_CMD (BrowserFavorites, APPCOMMAND_BROWSER_FAVORITES) KEY_MAP_WIN_CMD (BrowserFavorites, APPCOMMAND_BROWSER_FAVORITES)
KEY_MAP_ANDROID (BrowserFavorites, AKEYCODE_BOOKMARK)
// BrowserForward // BrowserForward
KEY_MAP_WIN (BrowserForward, VK_BROWSER_FORWARD) KEY_MAP_WIN (BrowserForward, VK_BROWSER_FORWARD)
KEY_MAP_WIN_CMD (BrowserForward, APPCOMMAND_BROWSER_FORWARD) KEY_MAP_WIN_CMD (BrowserForward, APPCOMMAND_BROWSER_FORWARD)
KEY_MAP_GTK (BrowserForward, GDK_Forward) KEY_MAP_GTK (BrowserForward, GDK_Forward)
KEY_MAP_ANDROID (BrowserForward, AKEYCODE_FORWARD)
// BrowserHome // BrowserHome
KEY_MAP_WIN (BrowserHome, VK_BROWSER_HOME) KEY_MAP_WIN (BrowserHome, VK_BROWSER_HOME)
@ -1008,7 +923,6 @@ KEY_MAP_GTK (BrowserRefresh, GDK_Reload)
KEY_MAP_WIN (BrowserSearch, VK_BROWSER_SEARCH) KEY_MAP_WIN (BrowserSearch, VK_BROWSER_SEARCH)
KEY_MAP_WIN_CMD (BrowserSearch, APPCOMMAND_BROWSER_SEARCH) KEY_MAP_WIN_CMD (BrowserSearch, APPCOMMAND_BROWSER_SEARCH)
KEY_MAP_GTK (BrowserSearch, GDK_Search) KEY_MAP_GTK (BrowserSearch, GDK_Search)
KEY_MAP_ANDROID (BrowserSearch, AKEYCODE_SEARCH)
// BrowserStop // BrowserStop
KEY_MAP_WIN (BrowserStop, VK_BROWSER_STOP) KEY_MAP_WIN (BrowserStop, VK_BROWSER_STOP)
@ -1019,88 +933,67 @@ KEY_MAP_GTK (BrowserStop, GDK_Stop)
* Mobile Phone Keys * Mobile Phone Keys
******************************************************************************/ ******************************************************************************/
// Call // Call
KEY_MAP_ANDROID (Call, AKEYCODE_CALL)
// Camera // Camera
KEY_MAP_ANDROID (Camera, AKEYCODE_CAMERA)
// CameraFocus // CameraFocus
KEY_MAP_ANDROID (CameraFocus, AKEYCODE_FOCUS)
// GoHome // GoHome
KEY_MAP_ANDROID (GoHome, AKEYCODE_HOME)
/****************************************************************************** /******************************************************************************
* TV Keys * TV Keys
******************************************************************************/ ******************************************************************************/
// TV // TV
KEY_MAP_ANDROID (TV, AKEYCODE_TV)
// TVInput // TVInput
KEY_MAP_ANDROID (TVInput, AKEYCODE_TV_INPUT)
// TVPower // TVPower
KEY_MAP_ANDROID (TVPower, AKEYCODE_TV_POWER)
/****************************************************************************** /******************************************************************************
* Media Controller Keys * Media Controller Keys
******************************************************************************/ ******************************************************************************/
// AVRInput // AVRInput
KEY_MAP_ANDROID (AVRInput, AKEYCODE_AVR_INPUT)
// AVRPower // AVRPower
KEY_MAP_ANDROID (AVRPower, AKEYCODE_AVR_POWER)
// ColorF0Red // ColorF0Red
KEY_MAP_GTK (ColorF0Red, GDK_Red) KEY_MAP_GTK (ColorF0Red, GDK_Red)
KEY_MAP_ANDROID (ColorF0Red, AKEYCODE_PROG_RED)
// ColorF1Green // ColorF1Green
KEY_MAP_GTK (ColorF1Green, GDK_Green) KEY_MAP_GTK (ColorF1Green, GDK_Green)
KEY_MAP_ANDROID (ColorF1Green, AKEYCODE_PROG_GREEN)
// ColorF2Yellow // ColorF2Yellow
KEY_MAP_GTK (ColorF2Yellow, GDK_Yellow) KEY_MAP_GTK (ColorF2Yellow, GDK_Yellow)
KEY_MAP_ANDROID (ColorF2Yellow, AKEYCODE_PROG_YELLOW)
// ColorF3Blue // ColorF3Blue
KEY_MAP_GTK (ColorF3Blue, GDK_Blue) KEY_MAP_GTK (ColorF3Blue, GDK_Blue)
KEY_MAP_ANDROID (ColorF3Blue, AKEYCODE_PROG_BLUE)
// Dimmer // Dimmer
KEY_MAP_GTK (Dimmer, GDK_BrightnessAdjust) KEY_MAP_GTK (Dimmer, GDK_BrightnessAdjust)
// Guide // Guide
KEY_MAP_ANDROID (Guide, AKEYCODE_GUIDE)
// Info // Info
KEY_MAP_ANDROID (Info, AKEYCODE_INFO)
// MediaFastForward // MediaFastForward
KEY_MAP_WIN_CMD (MediaFastForward, APPCOMMAND_MEDIA_FAST_FORWARD) KEY_MAP_WIN_CMD (MediaFastForward, APPCOMMAND_MEDIA_FAST_FORWARD)
KEY_MAP_GTK (MediaFastForward, GDK_AudioForward) KEY_MAP_GTK (MediaFastForward, GDK_AudioForward)
KEY_MAP_ANDROID (MediaFastForward, AKEYCODE_MEDIA_FAST_FORWARD)
// MediaLast // MediaLast
// PinPToggle // PinPToggle
KEY_MAP_ANDROID (PinPToggle, AKEYCODE_WINDOW)
// RandomToggle // RandomToggle
KEY_MAP_GTK (RandomToggle, GDK_AudioRandomPlay) KEY_MAP_GTK (RandomToggle, GDK_AudioRandomPlay)
// Settings // Settings
KEY_MAP_ANDROID (Settings, AKEYCODE_SETTINGS)
// STBInput // STBInput
KEY_MAP_ANDROID (STBInput, AKEYCODE_STB_INPUT)
// STBPower // STBPower
KEY_MAP_ANDROID (STBPower, AKEYCODE_STB_POWER)
// Subtitle // Subtitle
KEY_MAP_GTK (Subtitle, GDK_Subtitle) KEY_MAP_GTK (Subtitle, GDK_Subtitle)
KEY_MAP_ANDROID (Subtitle, AKEYCODE_CAPTIONS)
// VideoModeNext // VideoModeNext
KEY_MAP_GTK (VideoModeNext, GDK_Next_VMode) KEY_MAP_GTK (VideoModeNext, GDK_Next_VMode)
@ -1112,10 +1005,8 @@ KEY_MAP_WIN (ZoomToggle, VK_ZOOM)
* Keys not defined by any standards * Keys not defined by any standards
******************************************************************************/ ******************************************************************************/
// SoftLeft // SoftLeft
KEY_MAP_ANDROID (SoftLeft, AKEYCODE_SOFT_LEFT)
// SoftRight // SoftRight
KEY_MAP_ANDROID (SoftRight, AKEYCODE_SOFT_RIGHT)
#undef KEY_MAP_WIN #undef KEY_MAP_WIN
#undef KEY_MAP_WIN_JPN #undef KEY_MAP_WIN_JPN
@ -1124,4 +1015,3 @@ KEY_MAP_ANDROID (SoftRight, AKEYCODE_SOFT_RIGHT)
#undef KEY_MAP_WIN_CMD #undef KEY_MAP_WIN_CMD
#undef KEY_MAP_COCOA #undef KEY_MAP_COCOA
#undef KEY_MAP_GTK #undef KEY_MAP_GTK
#undef KEY_MAP_ANDROID

View file

@ -1,89 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ANRReporter.h"
#include "GeckoProfiler.h"
#include <unistd.h>
namespace mozilla {
bool
ANRReporter::RequestNativeStack(bool aUnwind)
{
if (profiler_is_active()) {
// Don't proceed if profiler is already running
return false;
}
// WARNING: we are on the ANR reporter thread at this point and it is
// generally unsafe to use the profiler from off the main thread. However,
// the risk here is limited because for most users, the profiler is not run
// elsewhere. See the discussion in Bug 863777, comment 13
const char *NATIVE_STACK_FEATURES[] =
{"leaf", "threads", "privacy"};
const char *NATIVE_STACK_UNWIND_FEATURES[] =
{"leaf", "threads", "privacy", "stackwalk"};
const char **features = NATIVE_STACK_FEATURES;
size_t features_size = sizeof(NATIVE_STACK_FEATURES);
if (aUnwind) {
features = NATIVE_STACK_UNWIND_FEATURES;
features_size = sizeof(NATIVE_STACK_UNWIND_FEATURES);
// We want the new unwinder if the unwind mode has not been set yet
putenv("MOZ_PROFILER_NEW=1");
}
const char *NATIVE_STACK_THREADS[] =
{"GeckoMain", "Compositor"};
// Buffer one sample and let the profiler wait a long time
profiler_start(100, 10000, features, features_size / sizeof(char*),
NATIVE_STACK_THREADS, sizeof(NATIVE_STACK_THREADS) / sizeof(char*));
return true;
}
jni::String::LocalRef
ANRReporter::GetNativeStack()
{
if (!profiler_is_active()) {
// Maybe profiler support is disabled?
return nullptr;
}
// Timeout if we don't get a profiler sample after 5 seconds.
const PRIntervalTime timeout = PR_SecondsToInterval(5);
const PRIntervalTime startTime = PR_IntervalNow();
// Pointer to a profile JSON string
typedef mozilla::UniquePtr<char[]> ProfilePtr;
ProfilePtr profile(profiler_get_profile());
while (profile && !strstr(profile.get(), "\"samples\":[{")) {
// no sample yet?
if (PR_IntervalNow() - startTime >= timeout) {
return nullptr;
}
usleep(100000ul); // Sleep for 100ms
profile = ProfilePtr(profiler_get_profile());
}
if (profile) {
return jni::String::Param(profile.get());
}
return nullptr;
}
void
ANRReporter::ReleaseNativeStack()
{
if (!profiler_is_active()) {
// Maybe profiler support is disabled?
return;
}
profiler_stop();
}
} // namespace

View file

@ -1,26 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ANRReporter_h__
#define ANRReporter_h__
#include "FennecJNINatives.h"
namespace mozilla {
class ANRReporter : public java::ANRReporter::Natives<ANRReporter>
{
private:
ANRReporter();
public:
static bool RequestNativeStack(bool aUnwind);
static jni::String::LocalRef GetNativeStack();
static void ReleaseNativeStack();
};
} // namespace
#endif // ANRReporter_h__

View file

@ -1,126 +0,0 @@
/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidAlerts.h"
#include "GeneratedJNIWrappers.h"
#include "nsAlertsUtils.h"
namespace mozilla {
namespace widget {
NS_IMPL_ISUPPORTS(AndroidAlerts, nsIAlertsService)
StaticAutoPtr<AndroidAlerts::ListenerMap> AndroidAlerts::sListenerMap;
NS_IMETHODIMP
AndroidAlerts::ShowAlertNotification(const nsAString & aImageUrl,
const nsAString & aAlertTitle,
const nsAString & aAlertText,
bool aAlertTextClickable,
const nsAString & aAlertCookie,
nsIObserver * aAlertListener,
const nsAString & aAlertName,
const nsAString & aBidi,
const nsAString & aLang,
const nsAString & aData,
nsIPrincipal * aPrincipal,
bool aInPrivateBrowsing,
bool aRequireInteraction)
{
MOZ_ASSERT_UNREACHABLE("Should be implemented by nsAlertsService.");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
AndroidAlerts::ShowAlert(nsIAlertNotification* aAlert,
nsIObserver* aAlertListener)
{
return ShowPersistentNotification(EmptyString(), aAlert, aAlertListener);
}
NS_IMETHODIMP
AndroidAlerts::ShowPersistentNotification(const nsAString& aPersistentData,
nsIAlertNotification* aAlert,
nsIObserver* aAlertListener)
{
// nsAlertsService disables our alerts backend if we ever return failure
// here. To keep the backend enabled, we always return NS_OK even if we
// encounter an error here.
nsresult rv;
nsAutoString imageUrl;
rv = aAlert->GetImageURL(imageUrl);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsAutoString title;
rv = aAlert->GetTitle(title);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsAutoString text;
rv = aAlert->GetText(text);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsAutoString cookie;
rv = aAlert->GetCookie(cookie);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsAutoString name;
rv = aAlert->GetName(name);
NS_ENSURE_SUCCESS(rv, NS_OK);
nsCOMPtr<nsIPrincipal> principal;
rv = aAlert->GetPrincipal(getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, NS_OK);
nsAutoString host;
nsAlertsUtils::GetSourceHostPort(principal, host);
if (aPersistentData.IsEmpty() && aAlertListener) {
if (!sListenerMap) {
sListenerMap = new ListenerMap();
}
// This will remove any observers already registered for this name.
sListenerMap->Put(name, aAlertListener);
}
java::GeckoAppShell::ShowNotification(
name, cookie, title, text, host, imageUrl,
!aPersistentData.IsEmpty() ? jni::StringParam(aPersistentData)
: jni::StringParam(nullptr));
return NS_OK;
}
NS_IMETHODIMP
AndroidAlerts::CloseAlert(const nsAString& aAlertName,
nsIPrincipal* aPrincipal)
{
// We delete the entry in sListenerMap later, when CloseNotification calls
// NotifyListener.
java::GeckoAppShell::CloseNotification(aAlertName);
return NS_OK;
}
void
AndroidAlerts::NotifyListener(const nsAString& aName, const char* aTopic,
const char16_t* aCookie)
{
if (!sListenerMap) {
return;
}
nsCOMPtr<nsIObserver> listener = sListenerMap->Get(aName);
if (!listener) {
return;
}
listener->Observe(nullptr, aTopic, aCookie);
if (NS_LITERAL_CSTRING("alertfinished").Equals(aTopic)) {
sListenerMap->Remove(aName);
}
}
} // namespace widget
} // namespace mozilla

View file

@ -1,44 +0,0 @@
/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_widget_AndroidAlerts_h__
#define mozilla_widget_AndroidAlerts_h__
#include "nsInterfaceHashtable.h"
#include "nsCOMPtr.h"
#include "nsHashKeys.h"
#include "nsIAlertsService.h"
#include "nsIObserver.h"
#include "mozilla/StaticPtr.h"
namespace mozilla {
namespace widget {
class AndroidAlerts : public nsIAlertsService
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIALERTSSERVICE
AndroidAlerts() {}
static void NotifyListener(const nsAString& aName, const char* aTopic,
const char16_t* aCookie);
protected:
virtual ~AndroidAlerts()
{
sListenerMap = nullptr;
}
using ListenerMap = nsInterfaceHashtable<nsStringHashKey, nsIObserver>;
static StaticAutoPtr<ListenerMap> sListenerMap;
};
} // namespace widget
} // namespace mozilla
#endif // nsAndroidAlerts_h__

File diff suppressed because it is too large Load diff

View file

@ -1,419 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidBridge_h__
#define AndroidBridge_h__
#include <jni.h>
#include <android/log.h>
#include <cstdlib>
#include <pthread.h>
#include "APKOpen.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "GeneratedJNIWrappers.h"
#include "nsIMutableArray.h"
#include "nsIMIMEInfo.h"
#include "nsColor.h"
#include "gfxRect.h"
#include "nsIAndroidBridge.h"
#include "nsIDOMDOMCursor.h"
#include "mozilla/Likely.h"
#include "mozilla/Mutex.h"
#include "mozilla/Types.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/jni/Utils.h"
#include "nsIObserver.h"
#include "nsDataHashtable.h"
#include "Units.h"
// Some debug #defines
// #define DEBUG_ANDROID_EVENTS
// #define DEBUG_ANDROID_WIDGET
class nsPIDOMWindowOuter;
namespace base {
class Thread;
} // end namespace base
typedef void* EGLSurface;
namespace mozilla {
class AutoLocalJNIFrame;
class Runnable;
namespace hal {
class BatteryInformation;
class NetworkInformation;
} // namespace hal
// The order and number of the members in this structure must correspond
// to the attrsAppearance array in GeckoAppShell.getSystemColors()
typedef struct AndroidSystemColors {
nscolor textColorPrimary;
nscolor textColorPrimaryInverse;
nscolor textColorSecondary;
nscolor textColorSecondaryInverse;
nscolor textColorTertiary;
nscolor textColorTertiaryInverse;
nscolor textColorHighlight;
nscolor colorForeground;
nscolor colorBackground;
nscolor panelColorForeground;
nscolor panelColorBackground;
} AndroidSystemColors;
class MessageCursorContinueCallback : public nsICursorContinueCallback
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSICURSORCONTINUECALLBACK
MessageCursorContinueCallback(int aRequestId)
: mRequestId(aRequestId)
{
}
private:
virtual ~MessageCursorContinueCallback()
{
}
int mRequestId;
};
class AndroidBridge final
{
public:
enum {
// Values for NotifyIME, in addition to values from the Gecko
// IMEMessage enum; use negative values here to prevent conflict
NOTIFY_IME_OPEN_VKB = -2,
NOTIFY_IME_REPLY_EVENT = -1,
};
enum {
LAYER_CLIENT_TYPE_NONE = 0,
LAYER_CLIENT_TYPE_GL = 2 // AndroidGeckoGLLayerClient
};
static bool IsJavaUiThread() {
return pthread_equal(pthread_self(), ::getJavaUiThread());
}
static void ConstructBridge();
static void DeconstructBridge();
static AndroidBridge *Bridge() {
return sBridge;
}
void ContentDocumentChanged(mozIDOMWindowProxy* aDOMWindow);
bool IsContentDocumentDisplayed(mozIDOMWindowProxy* aDOMWindow);
bool GetHandlersForURL(const nsAString& aURL,
nsIMutableArray* handlersArray = nullptr,
nsIHandlerApp **aDefaultApp = nullptr,
const nsAString& aAction = EmptyString());
bool GetHandlersForMimeType(const nsAString& aMimeType,
nsIMutableArray* handlersArray = nullptr,
nsIHandlerApp **aDefaultApp = nullptr,
const nsAString& aAction = EmptyString());
bool GetHWEncoderCapability();
bool GetHWDecoderCapability();
void GetMimeTypeFromExtensions(const nsACString& aFileExt, nsCString& aMimeType);
void GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt);
bool GetClipboardText(nsAString& aText);
int GetDPI();
int GetScreenDepth();
void Vibrate(const nsTArray<uint32_t>& aPattern);
void GetSystemColors(AndroidSystemColors *aColors);
void GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf);
bool GetStaticStringField(const char *classID, const char *field, nsAString &result, JNIEnv* env = nullptr);
bool GetStaticIntField(const char *className, const char *fieldName, int32_t* aInt, JNIEnv* env = nullptr);
// Returns a global reference to the Context for Fennec's Activity. The
// caller is responsible for ensuring this doesn't leak by calling
// DeleteGlobalRef() when the context is no longer needed.
jobject GetGlobalContextRef(void);
void HandleGeckoMessage(JSContext* cx, JS::HandleObject message);
void GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo);
void GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo);
// These methods don't use a ScreenOrientation because it's an
// enum and that would require including the header which requires
// include IPC headers which requires including basictypes.h which
// requires a lot of changes...
uint32_t GetScreenOrientation();
uint16_t GetScreenAngle();
int GetAPIVersion() { return mAPIVersion; }
nsresult GetProxyForURI(const nsACString & aSpec,
const nsACString & aScheme,
const nsACString & aHost,
const int32_t aPort,
nsACString & aResult);
bool PumpMessageLoop();
// Utility methods.
static jstring NewJavaString(JNIEnv* env, const char16_t* string, uint32_t len);
static jstring NewJavaString(JNIEnv* env, const nsAString& string);
static jstring NewJavaString(JNIEnv* env, const char* string);
static jstring NewJavaString(JNIEnv* env, const nsACString& string);
static jstring NewJavaString(AutoLocalJNIFrame* frame, const char16_t* string, uint32_t len);
static jstring NewJavaString(AutoLocalJNIFrame* frame, const nsAString& string);
static jstring NewJavaString(AutoLocalJNIFrame* frame, const char* string);
static jstring NewJavaString(AutoLocalJNIFrame* frame, const nsACString& string);
static jfieldID GetFieldID(JNIEnv* env, jclass jClass, const char* fieldName, const char* fieldType);
static jfieldID GetStaticFieldID(JNIEnv* env, jclass jClass, const char* fieldName, const char* fieldType);
static jmethodID GetMethodID(JNIEnv* env, jclass jClass, const char* methodName, const char* methodType);
static jmethodID GetStaticMethodID(JNIEnv* env, jclass jClass, const char* methodName, const char* methodType);
static jni::Object::LocalRef ChannelCreate(jni::Object::Param);
static void InputStreamClose(jni::Object::Param obj);
static uint32_t InputStreamAvailable(jni::Object::Param obj);
static nsresult InputStreamRead(jni::Object::Param obj, char *aBuf, uint32_t aCount, uint32_t *aRead);
protected:
static nsDataHashtable<nsStringHashKey, nsString> sStoragePaths;
static AndroidBridge* sBridge;
AndroidBridge();
~AndroidBridge();
int mAPIVersion;
// intput stream
jclass jReadableByteChannel;
jclass jChannels;
jmethodID jChannelCreate;
jmethodID jByteBufferRead;
jclass jInputStream;
jmethodID jClose;
jmethodID jAvailable;
jmethodID jCalculateLength;
// some convinient types to have around
jclass jStringClass;
jni::Object::GlobalRef mMessageQueue;
jfieldID mMessageQueueMessages;
jmethodID mMessageQueueNext;
private:
class DelayedTask;
nsTArray<DelayedTask> mUiTaskQueue;
mozilla::Mutex mUiTaskQueueLock;
public:
void PostTaskToUiThread(already_AddRefed<Runnable> aTask, int aDelayMs);
int64_t RunDelayedUiThreadTasks();
};
class AutoJNIClass {
private:
JNIEnv* const mEnv;
const jclass mClass;
public:
AutoJNIClass(JNIEnv* jEnv, const char* name)
: mEnv(jEnv)
, mClass(jni::GetClassRef(jEnv, name))
{}
~AutoJNIClass() {
mEnv->DeleteLocalRef(mClass);
}
jclass getRawRef() const {
return mClass;
}
jclass getGlobalRef() const {
return static_cast<jclass>(mEnv->NewGlobalRef(mClass));
}
jfieldID getField(const char* name, const char* type) const {
return AndroidBridge::GetFieldID(mEnv, mClass, name, type);
}
jfieldID getStaticField(const char* name, const char* type) const {
return AndroidBridge::GetStaticFieldID(mEnv, mClass, name, type);
}
jmethodID getMethod(const char* name, const char* type) const {
return AndroidBridge::GetMethodID(mEnv, mClass, name, type);
}
jmethodID getStaticMethod(const char* name, const char* type) const {
return AndroidBridge::GetStaticMethodID(mEnv, mClass, name, type);
}
};
class AutoJObject {
public:
AutoJObject(JNIEnv* aJNIEnv = nullptr) : mObject(nullptr)
{
mJNIEnv = aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv();
}
AutoJObject(JNIEnv* aJNIEnv, jobject aObject)
{
mJNIEnv = aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv();
mObject = aObject;
}
~AutoJObject() {
if (mObject)
mJNIEnv->DeleteLocalRef(mObject);
}
jobject operator=(jobject aObject)
{
if (mObject) {
mJNIEnv->DeleteLocalRef(mObject);
}
return mObject = aObject;
}
operator jobject() {
return mObject;
}
private:
JNIEnv* mJNIEnv;
jobject mObject;
};
class AutoLocalJNIFrame {
public:
AutoLocalJNIFrame(int nEntries = 15)
: mEntries(nEntries)
, mJNIEnv(jni::GetGeckoThreadEnv())
, mHasFrameBeenPushed(false)
{
MOZ_ASSERT(mJNIEnv);
Push();
}
AutoLocalJNIFrame(JNIEnv* aJNIEnv, int nEntries = 15)
: mEntries(nEntries)
, mJNIEnv(aJNIEnv ? aJNIEnv : jni::GetGeckoThreadEnv())
, mHasFrameBeenPushed(false)
{
MOZ_ASSERT(mJNIEnv);
Push();
}
~AutoLocalJNIFrame() {
if (mHasFrameBeenPushed) {
Pop();
}
}
JNIEnv* GetEnv() {
return mJNIEnv;
}
bool CheckForException() {
if (mJNIEnv->ExceptionCheck()) {
MOZ_CATCH_JNI_EXCEPTION(mJNIEnv);
return true;
}
return false;
}
// Note! Calling Purge makes all previous local refs created in
// the AutoLocalJNIFrame's scope INVALID; be sure that you locked down
// any local refs that you need to keep around in global refs!
void Purge() {
Pop();
Push();
}
template <typename ReturnType = jobject>
ReturnType Pop(ReturnType aResult = nullptr) {
MOZ_ASSERT(mHasFrameBeenPushed);
mHasFrameBeenPushed = false;
return static_cast<ReturnType>(
mJNIEnv->PopLocalFrame(static_cast<jobject>(aResult)));
}
private:
void Push() {
MOZ_ASSERT(!mHasFrameBeenPushed);
// Make sure there is enough space to store a local ref to the
// exception. I am not completely sure this is needed, but does
// not hurt.
if (mJNIEnv->PushLocalFrame(mEntries + 1) != 0) {
CheckForException();
return;
}
mHasFrameBeenPushed = true;
}
const int mEntries;
JNIEnv* const mJNIEnv;
bool mHasFrameBeenPushed;
};
}
#define NS_ANDROIDBRIDGE_CID \
{ 0x0FE2321D, 0xEBD9, 0x467D, \
{ 0xA7, 0x43, 0x03, 0xA6, 0x8D, 0x40, 0x59, 0x9E } }
class nsAndroidBridge final : public nsIAndroidBridge,
public nsIObserver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIANDROIDBRIDGE
NS_DECL_NSIOBSERVER
nsAndroidBridge();
private:
~nsAndroidBridge();
void AddObservers();
void RemoveObservers();
void UpdateAudioPlayingWindows(uint64_t aWindowId, bool aPlaying);
nsTArray<uint64_t> mAudioPlayingWindows;
protected:
};
#endif /* AndroidBridge_h__ */

View file

@ -1,13 +0,0 @@
#ifndef ALOG
#if defined(DEBUG) || defined(FORCE_ALOG)
#define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gecko" , ## args)
#else
#define ALOG(args...) ((void)0)
#endif
#endif
#ifdef DEBUG
#define ALOG_BRIDGE(args...) ALOG(args)
#else
#define ALOG_BRIDGE(args...) ((void)0)
#endif

View file

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=2 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidCompositorWidget.h"
#include "nsWindow.h"
namespace mozilla {
namespace widget {
void
AndroidCompositorWidget::SetFirstPaintViewport(const LayerIntPoint& aOffset,
const CSSToLayerScale& aZoom,
const CSSRect& aCssPageRect)
{
auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
if (!layerClient) {
return;
}
layerClient->SetFirstPaintViewport(
float(aOffset.x), float(aOffset.y), aZoom.scale, aCssPageRect.x,
aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
}
void
AndroidCompositorWidget::SyncFrameMetrics(const ParentLayerPoint& aScrollOffset,
const CSSToParentLayerScale& aZoom,
const CSSRect& aCssPageRect,
const CSSRect& aDisplayPort,
const CSSToLayerScale& aPaintedResolution,
bool aLayersUpdated,
int32_t aPaintSyncId,
ScreenMargin& aFixedLayerMargins)
{
auto layerClient = static_cast<nsWindow*>(RealWidget())->GetLayerClient();
if (!layerClient) {
return;
}
// convert the displayport rect from document-relative CSS pixels to
// document-relative device pixels
LayerIntRect dp = gfx::RoundedToInt(aDisplayPort * aPaintedResolution);
java::ViewTransform::LocalRef viewTransform = layerClient->SyncFrameMetrics(
aScrollOffset.x, aScrollOffset.y, aZoom.scale,
aCssPageRect.x, aCssPageRect.y,
aCssPageRect.XMost(), aCssPageRect.YMost(),
dp.x, dp.y, dp.width, dp.height,
aPaintedResolution.scale, aLayersUpdated, aPaintSyncId);
MOZ_ASSERT(viewTransform, "No view transform object!");
aFixedLayerMargins.top = viewTransform->FixedLayerMarginTop();
aFixedLayerMargins.right = viewTransform->FixedLayerMarginRight();
aFixedLayerMargins.bottom = viewTransform->FixedLayerMarginBottom();
aFixedLayerMargins.left = viewTransform->FixedLayerMarginLeft();
}
} // namespace widget
} // namespace mozilla

View file

@ -1,44 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_widget_AndroidCompositorWidget_h
#define mozilla_widget_AndroidCompositorWidget_h
#include "mozilla/widget/InProcessCompositorWidget.h"
namespace mozilla {
namespace widget {
/**
* AndroidCompositorWidget inherits from InProcessCompositorWidget because
* Android does not support OOP compositing yet. Once it does,
* AndroidCompositorWidget will be made to inherit from CompositorWidget
* instead.
*/
class AndroidCompositorWidget final : public InProcessCompositorWidget
{
public:
using InProcessCompositorWidget::InProcessCompositorWidget;
AndroidCompositorWidget* AsAndroid() override { return this; }
void SetFirstPaintViewport(const LayerIntPoint& aOffset,
const CSSToLayerScale& aZoom,
const CSSRect& aCssPageRect);
void SyncFrameMetrics(const ParentLayerPoint& aScrollOffset,
const CSSToParentLayerScale& aZoom,
const CSSRect& aCssPageRect,
const CSSRect& aDisplayPort,
const CSSToLayerScale& aPaintedResolution,
bool aLayersUpdated,
int32_t aPaintSyncId,
ScreenMargin& aFixedLayerMargins);
};
} // namespace widget
} // namespace mozilla
#endif // mozilla_widget_AndroidCompositorWidget_h

View file

@ -1,157 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidContentController.h"
#include "AndroidBridge.h"
#include "base/message_loop.h"
#include "mozilla/layers/APZCCallbackHelper.h"
#include "mozilla/layers/IAPZCTreeManager.h"
#include "nsIObserverService.h"
#include "nsLayoutUtils.h"
#include "nsWindow.h"
using mozilla::layers::IAPZCTreeManager;
namespace mozilla {
namespace widget {
void
AndroidContentController::Destroy()
{
mAndroidWindow = nullptr;
ChromeProcessController::Destroy();
}
void
AndroidContentController::NotifyDefaultPrevented(IAPZCTreeManager* aManager,
uint64_t aInputBlockId,
bool aDefaultPrevented)
{
if (!AndroidBridge::IsJavaUiThread()) {
// The notification must reach the APZ on the Java UI thread (aka the
// APZ "controller" thread) but we get it from the Gecko thread, so we
// have to throw it onto the other thread.
AndroidBridge::Bridge()->PostTaskToUiThread(NewRunnableMethod<uint64_t, bool>(
aManager, &IAPZCTreeManager::ContentReceivedInputBlock,
aInputBlockId, aDefaultPrevented), 0);
return;
}
aManager->ContentReceivedInputBlock(aInputBlockId, aDefaultPrevented);
}
void
AndroidContentController::DispatchSingleTapToObservers(const LayoutDevicePoint& aPoint,
const ScrollableLayerGuid& aGuid) const
{
nsIContent* content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
nsPresContext* context = content
? mozilla::layers::APZCCallbackHelper::GetPresContextForContent(content)
: nullptr;
if (!context) {
return;
}
CSSPoint point = mozilla::layers::APZCCallbackHelper::ApplyCallbackTransform(
aPoint / context->CSSToDevPixelScale(), aGuid);
nsPresContext* rcdContext = context->GetToplevelContentDocumentPresContext();
if (rcdContext && rcdContext->PresShell()->ScaleToResolution()) {
// We need to convert from the root document to the root content document,
// by unapplying the resolution that's on the content document.
const float resolution = rcdContext->PresShell()->GetResolution();
point.x /= resolution;
point.y /= resolution;
}
CSSIntPoint rounded = RoundedToInt(point);
nsAppShell::PostEvent([rounded] {
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
if (!obsServ) {
return;
}
nsPrintfCString data("{\"x\":%d,\"y\":%d}", rounded.x, rounded.y);
obsServ->NotifyObservers(nullptr, "Gesture:SingleTap",
NS_ConvertASCIItoUTF16(data).get());
});
}
void
AndroidContentController::HandleTap(TapType aType, const LayoutDevicePoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId)
{
// This function will get invoked first on the Java UI thread, and then
// again on the main thread (because of the code in ChromeProcessController::
// HandleTap). We want to post the SingleTap message once; it can be
// done from either thread but we need access to the callback transform
// so we do it from the main thread.
if (NS_IsMainThread() &&
(aType == TapType::eSingleTap || aType == TapType::eSecondTap)) {
DispatchSingleTapToObservers(aPoint, aGuid);
}
ChromeProcessController::HandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId);
}
void
AndroidContentController::PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs)
{
AndroidBridge::Bridge()->PostTaskToUiThread(Move(aTask), aDelayMs);
}
void
AndroidContentController::UpdateOverscrollVelocity(const float aX, const float aY, const bool aIsRootContent)
{
if (aIsRootContent && mAndroidWindow) {
mAndroidWindow->UpdateOverscrollVelocity(aX, aY);
}
}
void
AndroidContentController::UpdateOverscrollOffset(const float aX, const float aY, const bool aIsRootContent)
{
if (aIsRootContent && mAndroidWindow) {
mAndroidWindow->UpdateOverscrollOffset(aX, aY);
}
}
void
AndroidContentController::SetScrollingRootContent(const bool isRootContent)
{
if (mAndroidWindow) {
mAndroidWindow->SetScrollingRootContent(isRootContent);
}
}
void
AndroidContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg)
{
// This function may get invoked twice, if the first invocation is not on
// the main thread then the ChromeProcessController version of this function
// will redispatch to the main thread. We want to make sure that our handling
// only happens on the main thread.
ChromeProcessController::NotifyAPZStateChange(aGuid, aChange, aArg);
if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
if (aChange == layers::GeckoContentController::APZStateChange::eTransformEnd) {
// This is used by tests to determine when the APZ is done doing whatever
// it's doing. XXX generify this as needed when writing additional tests.
observerService->NotifyObservers(nullptr, "APZ:TransformEnd", nullptr);
observerService->NotifyObservers(nullptr, "PanZoom:StateChange", u"NOTHING");
} else if (aChange == layers::GeckoContentController::APZStateChange::eTransformBegin) {
observerService->NotifyObservers(nullptr, "PanZoom:StateChange", u"PANNING");
}
}
}
} // namespace widget
} // namespace mozilla

View file

@ -1,59 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidContentController_h__
#define AndroidContentController_h__
#include "mozilla/layers/ChromeProcessController.h"
#include "mozilla/EventForwards.h" // for Modifiers
#include "mozilla/StaticPtr.h"
#include "mozilla/TimeStamp.h"
#include "nsIDOMWindowUtils.h"
#include "nsTArray.h"
#include "nsWindow.h"
namespace mozilla {
namespace layers {
class APZEventState;
class IAPZCTreeManager;
}
namespace widget {
class AndroidContentController final
: public mozilla::layers::ChromeProcessController
{
public:
AndroidContentController(nsWindow* aWindow,
mozilla::layers::APZEventState* aAPZEventState,
mozilla::layers::IAPZCTreeManager* aAPZCTreeManager)
: mozilla::layers::ChromeProcessController(aWindow, aAPZEventState, aAPZCTreeManager)
, mAndroidWindow(aWindow)
{}
// ChromeProcessController methods
virtual void Destroy() override;
void HandleTap(TapType aType, const LayoutDevicePoint& aPoint, Modifiers aModifiers,
const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) override;
void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) override;
void UpdateOverscrollVelocity(const float aX, const float aY, const bool aIsRootContent) override;
void UpdateOverscrollOffset(const float aX, const float aY, const bool aIsRootContent) override;
void SetScrollingRootContent(const bool isRootContent) override;
void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
APZStateChange aChange,
int aArg) override;
static void NotifyDefaultPrevented(mozilla::layers::IAPZCTreeManager* aManager,
uint64_t aInputBlockId, bool aDefaultPrevented);
private:
nsWindow* mAndroidWindow;
void DispatchSingleTapToObservers(const LayoutDevicePoint& aPoint,
const ScrollableLayerGuid& aGuid) const;
};
} // namespace widget
} // namespace mozilla
#endif

View file

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidDirectTexture_h_
#define AndroidDirectTexture_h_
#include "gfxTypes.h"
#include "mozilla/Mutex.h"
#include "AndroidGraphicBuffer.h"
#include "nsRect.h"
namespace mozilla {
/**
* This is a thread safe wrapper around AndroidGraphicBuffer that handles
* double buffering. Each call to Bind() flips the buffer when necessary.
*
* You need to be careful when destroying an instance of this class. If either
* buffer is locked by the application of the driver/hardware, bad things will
* happen. Be sure that the OpenGL texture is no longer on the screen.
*/
class AndroidDirectTexture
{
public:
AndroidDirectTexture(uint32_t width, uint32_t height, uint32_t usage, gfxImageFormat format);
virtual ~AndroidDirectTexture();
bool Lock(uint32_t usage, unsigned char **bits);
bool Lock(uint32_t usage, const nsIntRect& rect, unsigned char **bits);
bool Unlock(bool aFlip = true);
bool Reallocate(uint32_t aWidth, uint32_t aHeight);
bool Reallocate(uint32_t aWidth, uint32_t aHeight, gfxImageFormat aFormat);
uint32_t Width() { return mWidth; }
uint32_t Height() { return mHeight; }
bool Bind();
private:
mozilla::Mutex mLock;
bool mNeedFlip;
uint32_t mWidth;
uint32_t mHeight;
gfxImageFormat mFormat;
AndroidGraphicBuffer* mFrontBuffer;
AndroidGraphicBuffer* mBackBuffer;
AndroidGraphicBuffer* mPendingReallocBuffer;
void ReallocPendingBuffer();
};
} /* mozilla */
#endif /* AndroidDirectTexture_h_ */

View file

@ -1,72 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidGraphicBuffer_h_
#define AndroidGraphicBuffer_h_
#include "gfxTypes.h"
#include "nsRect.h"
typedef void* EGLImageKHR;
typedef void* EGLClientBuffer;
namespace mozilla {
/**
* This class allows access to Android's direct texturing mechanism. Locking
* the buffer gives you a pointer you can read/write to directly. It is fully
* threadsafe, but you probably really want to use the AndroidDirectTexture
* class which will handle double buffering.
*
* In order to use the buffer in OpenGL, just call Bind() and it will attach
* to whatever texture is bound to GL_TEXTURE_2D.
*/
class AndroidGraphicBuffer
{
public:
enum {
UsageSoftwareRead = 1,
UsageSoftwareWrite = 1 << 1,
UsageTexture = 1 << 2,
UsageTarget = 1 << 3,
Usage2D = 1 << 4
};
AndroidGraphicBuffer(uint32_t width, uint32_t height, uint32_t usage, gfxImageFormat format);
virtual ~AndroidGraphicBuffer();
int Lock(uint32_t usage, unsigned char **bits);
int Lock(uint32_t usage, const nsIntRect& rect, unsigned char **bits);
int Unlock();
bool Reallocate(uint32_t aWidth, uint32_t aHeight, gfxImageFormat aFormat);
uint32_t Width() { return mWidth; }
uint32_t Height() { return mHeight; }
bool Bind();
static bool IsBlacklisted();
private:
uint32_t mWidth;
uint32_t mHeight;
uint32_t mUsage;
gfxImageFormat mFormat;
bool EnsureInitialized();
bool EnsureEGLImage();
void DestroyBuffer();
bool EnsureBufferCreated();
uint32_t GetAndroidUsage(uint32_t aUsage);
uint32_t GetAndroidFormat(gfxImageFormat aFormat);
void *mHandle;
void *mEGLImage;
};
} /* mozilla */
#endif /* AndroidGraphicBuffer_h_ */

View file

@ -1,47 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Hal.h"
#include "nsIFile.h"
#include "nsString.h"
#include "AndroidBridge.h"
#include "AndroidContentController.h"
#include "AndroidGraphicBuffer.h"
#include <jni.h>
#include <pthread.h>
#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>
#include "nsAppShell.h"
#include "nsWindow.h"
#include <android/log.h>
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "nsThreadUtils.h"
#include "mozilla/Unused.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "nsPluginInstanceOwner.h"
#include "AndroidSurfaceTexture.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::layers;
using namespace mozilla::widget;
/* Forward declare all the JNI methods as extern "C" */
extern "C" {
/*
* Incoming JNI methods
*/
}

View file

@ -1,140 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <android/log.h>
#include <dlfcn.h>
#include <prthread.h>
#include "mozilla/DebugOnly.h"
#include "mozilla/Assertions.h"
#include "mozilla/SyncRunnable.h"
#include "nsThreadUtils.h"
#include "AndroidBridge.h"
extern "C" {
jclass __jsjni_GetGlobalClassRef(const char *className);
}
class GetGlobalClassRefRunnable : public mozilla::Runnable {
public:
GetGlobalClassRefRunnable(const char *className, jclass *foundClass) :
mClassName(className), mResult(foundClass) {}
NS_IMETHOD Run() override {
*mResult = __jsjni_GetGlobalClassRef(mClassName);
return NS_OK;
}
private:
const char *mClassName;
jclass *mResult;
};
extern "C" {
__attribute__ ((visibility("default")))
jclass
jsjni_FindClass(const char *className) {
// FindClass outside the main thread will run into problems due
// to missing the classpath
MOZ_ASSERT(NS_IsMainThread());
JNIEnv *env = mozilla::jni::GetGeckoThreadEnv();
return env->FindClass(className);
}
jclass
__jsjni_GetGlobalClassRef(const char *className) {
// root class globally
JNIEnv *env = mozilla::jni::GetGeckoThreadEnv();
jclass globalRef = static_cast<jclass>(env->NewGlobalRef(env->FindClass(className)));
if (!globalRef)
return nullptr;
// return the newly create global reference
return globalRef;
}
__attribute__ ((visibility("default")))
jclass
jsjni_GetGlobalClassRef(const char *className) {
if (NS_IsMainThread()) {
return __jsjni_GetGlobalClassRef(className);
}
nsCOMPtr<nsIThread> mainThread;
mozilla::DebugOnly<nsresult> rv = NS_GetMainThread(getter_AddRefs(mainThread));
MOZ_ASSERT(NS_SUCCEEDED(rv));
jclass foundClass;
nsCOMPtr<nsIRunnable> runnable_ref(new GetGlobalClassRefRunnable(className,
&foundClass));
RefPtr<mozilla::SyncRunnable> sr = new mozilla::SyncRunnable(runnable_ref);
sr->DispatchToThread(mainThread);
if (!foundClass)
return nullptr;
return foundClass;
}
__attribute__ ((visibility("default")))
jmethodID
jsjni_GetStaticMethodID(jclass methodClass,
const char *methodName,
const char *signature) {
JNIEnv *env = mozilla::jni::GetGeckoThreadEnv();
return env->GetStaticMethodID(methodClass, methodName, signature);
}
__attribute__ ((visibility("default")))
bool
jsjni_ExceptionCheck() {
JNIEnv *env = mozilla::jni::GetGeckoThreadEnv();
return env->ExceptionCheck();
}
__attribute__ ((visibility("default")))
void
jsjni_CallStaticVoidMethodA(jclass cls,
jmethodID method,
jvalue *values) {
JNIEnv *env = mozilla::jni::GetGeckoThreadEnv();
mozilla::AutoLocalJNIFrame jniFrame(env);
env->CallStaticVoidMethodA(cls, method, values);
}
__attribute__ ((visibility("default")))
int
jsjni_CallStaticIntMethodA(jclass cls,
jmethodID method,
jvalue *values) {
JNIEnv *env = mozilla::jni::GetGeckoThreadEnv();
mozilla::AutoLocalJNIFrame jniFrame(env);
return env->CallStaticIntMethodA(cls, method, values);
}
__attribute__ ((visibility("default")))
jobject jsjni_GetGlobalContextRef() {
return mozilla::AndroidBridge::Bridge()->GetGlobalContextRef();
}
__attribute__ ((visibility("default")))
JavaVM* jsjni_GetVM() {
JavaVM* jvm;
JNIEnv* const env = mozilla::jni::GetGeckoThreadEnv();
MOZ_ALWAYS_TRUE(!env->GetJavaVM(&jvm));
return jvm;
}
__attribute__ ((visibility("default")))
JNIEnv* jsjni_GetJNIForThread() {
return mozilla::jni::GetEnvForThread();
}
// For compatibility with JNI.jsm; some addons bundle their own JNI.jsm,
// so we cannot just change the function name used in JNI.jsm.
__attribute__ ((visibility("default")))
JNIEnv* GetJNIForThread() {
return mozilla::jni::GetEnvForThread();
}
}

View file

@ -1,34 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidJNIWrapper_h__
#define AndroidJNIWrapper_h__
#include "mozilla/Types.h"
#include <jni.h>
#include <android/log.h>
extern "C" MOZ_EXPORT jclass jsjni_FindClass(const char *className);
/**
* JNIEnv::FindClass alternative.
* Callable from any thread, including code
* invoked via the JNI that doesn't have MOZILLA_INTERNAL_API defined.
* The caller is responsible for ensuring that the class is not leaked by
* calling DeleteGlobalRef at an appropriate time.
*/
extern "C" MOZ_EXPORT jclass jsjni_GetGlobalClassRef(const char *className);
extern "C" MOZ_EXPORT jmethodID jsjni_GetStaticMethodID(jclass methodClass,
const char *methodName,
const char *signature);
extern "C" MOZ_EXPORT bool jsjni_ExceptionCheck();
extern "C" MOZ_EXPORT void jsjni_CallStaticVoidMethodA(jclass cls, jmethodID method, jvalue *values);
extern "C" MOZ_EXPORT int jsjni_CallStaticIntMethodA(jclass cls, jmethodID method, jvalue *values);
extern "C" MOZ_EXPORT jobject jsjni_GetGlobalContextRef();
extern "C" MOZ_EXPORT JavaVM* jsjni_GetVM();
extern "C" MOZ_EXPORT JNIEnv* jsjni_GetJNIForThread();
#endif /* AndroidJNIWrapper_h__ */

View file

@ -1,62 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AndroidJavaWrappers.h"
using namespace mozilla;
nsJNIString::nsJNIString(jstring jstr, JNIEnv *jenv)
{
if (!jstr) {
SetIsVoid(true);
return;
}
JNIEnv *jni = jenv;
if (!jni) {
jni = jni::GetGeckoThreadEnv();
}
const jchar* jCharPtr = jni->GetStringChars(jstr, nullptr);
if (!jCharPtr) {
SetIsVoid(true);
return;
}
jsize len = jni->GetStringLength(jstr);
if (len <= 0) {
SetIsVoid(true);
} else {
Assign(reinterpret_cast<const char16_t*>(jCharPtr), len);
}
jni->ReleaseStringChars(jstr, jCharPtr);
}
nsJNICString::nsJNICString(jstring jstr, JNIEnv *jenv)
{
if (!jstr) {
SetIsVoid(true);
return;
}
JNIEnv *jni = jenv;
if (!jni) {
jni = jni::GetGeckoThreadEnv();
}
const char* jCharPtr = jni->GetStringUTFChars(jstr, nullptr);
if (!jCharPtr) {
SetIsVoid(true);
return;
}
jsize len = jni->GetStringUTFLength(jstr);
if (len <= 0) {
SetIsVoid(true);
} else {
Assign(jCharPtr, len);
}
jni->ReleaseStringUTFChars(jstr, jCharPtr);
}

View file

@ -1,218 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidJavaWrappers_h__
#define AndroidJavaWrappers_h__
#include <jni.h>
#include <android/input.h>
#include <android/log.h>
#include <android/api-level.h>
#include "nsRect.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsIAndroidBridge.h"
#include "mozilla/gfx/Rect.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/EventForwards.h"
#include "InputData.h"
#include "Units.h"
#include "FrameMetrics.h"
//#define FORCE_ALOG 1
class nsIAndroidDisplayport;
class nsIWidget;
namespace mozilla {
enum {
// These keycode masks are not defined in android/keycodes.h:
#if __ANDROID_API__ < 13
AKEYCODE_ESCAPE = 111,
AKEYCODE_FORWARD_DEL = 112,
AKEYCODE_CTRL_LEFT = 113,
AKEYCODE_CTRL_RIGHT = 114,
AKEYCODE_CAPS_LOCK = 115,
AKEYCODE_SCROLL_LOCK = 116,
AKEYCODE_META_LEFT = 117,
AKEYCODE_META_RIGHT = 118,
AKEYCODE_FUNCTION = 119,
AKEYCODE_SYSRQ = 120,
AKEYCODE_BREAK = 121,
AKEYCODE_MOVE_HOME = 122,
AKEYCODE_MOVE_END = 123,
AKEYCODE_INSERT = 124,
AKEYCODE_FORWARD = 125,
AKEYCODE_MEDIA_PLAY = 126,
AKEYCODE_MEDIA_PAUSE = 127,
AKEYCODE_MEDIA_CLOSE = 128,
AKEYCODE_MEDIA_EJECT = 129,
AKEYCODE_MEDIA_RECORD = 130,
AKEYCODE_F1 = 131,
AKEYCODE_F2 = 132,
AKEYCODE_F3 = 133,
AKEYCODE_F4 = 134,
AKEYCODE_F5 = 135,
AKEYCODE_F6 = 136,
AKEYCODE_F7 = 137,
AKEYCODE_F8 = 138,
AKEYCODE_F9 = 139,
AKEYCODE_F10 = 140,
AKEYCODE_F11 = 141,
AKEYCODE_F12 = 142,
AKEYCODE_NUM_LOCK = 143,
AKEYCODE_NUMPAD_0 = 144,
AKEYCODE_NUMPAD_1 = 145,
AKEYCODE_NUMPAD_2 = 146,
AKEYCODE_NUMPAD_3 = 147,
AKEYCODE_NUMPAD_4 = 148,
AKEYCODE_NUMPAD_5 = 149,
AKEYCODE_NUMPAD_6 = 150,
AKEYCODE_NUMPAD_7 = 151,
AKEYCODE_NUMPAD_8 = 152,
AKEYCODE_NUMPAD_9 = 153,
AKEYCODE_NUMPAD_DIVIDE = 154,
AKEYCODE_NUMPAD_MULTIPLY = 155,
AKEYCODE_NUMPAD_SUBTRACT = 156,
AKEYCODE_NUMPAD_ADD = 157,
AKEYCODE_NUMPAD_DOT = 158,
AKEYCODE_NUMPAD_COMMA = 159,
AKEYCODE_NUMPAD_ENTER = 160,
AKEYCODE_NUMPAD_EQUALS = 161,
AKEYCODE_NUMPAD_LEFT_PAREN = 162,
AKEYCODE_NUMPAD_RIGHT_PAREN = 163,
AKEYCODE_VOLUME_MUTE = 164,
AKEYCODE_INFO = 165,
AKEYCODE_CHANNEL_UP = 166,
AKEYCODE_CHANNEL_DOWN = 167,
AKEYCODE_ZOOM_IN = 168,
AKEYCODE_ZOOM_OUT = 169,
AKEYCODE_TV = 170,
AKEYCODE_WINDOW = 171,
AKEYCODE_GUIDE = 172,
AKEYCODE_DVR = 173,
AKEYCODE_BOOKMARK = 174,
AKEYCODE_CAPTIONS = 175,
AKEYCODE_SETTINGS = 176,
AKEYCODE_TV_POWER = 177,
AKEYCODE_TV_INPUT = 178,
AKEYCODE_STB_POWER = 179,
AKEYCODE_STB_INPUT = 180,
AKEYCODE_AVR_POWER = 181,
AKEYCODE_AVR_INPUT = 182,
AKEYCODE_PROG_RED = 183,
AKEYCODE_PROG_GREEN = 184,
AKEYCODE_PROG_YELLOW = 185,
AKEYCODE_PROG_BLUE = 186,
AKEYCODE_APP_SWITCH = 187,
AKEYCODE_BUTTON_1 = 188,
AKEYCODE_BUTTON_2 = 189,
AKEYCODE_BUTTON_3 = 190,
AKEYCODE_BUTTON_4 = 191,
AKEYCODE_BUTTON_5 = 192,
AKEYCODE_BUTTON_6 = 193,
AKEYCODE_BUTTON_7 = 194,
AKEYCODE_BUTTON_8 = 195,
AKEYCODE_BUTTON_9 = 196,
AKEYCODE_BUTTON_10 = 197,
AKEYCODE_BUTTON_11 = 198,
AKEYCODE_BUTTON_12 = 199,
AKEYCODE_BUTTON_13 = 200,
AKEYCODE_BUTTON_14 = 201,
AKEYCODE_BUTTON_15 = 202,
AKEYCODE_BUTTON_16 = 203,
#endif
#if __ANDROID_API__ < 14
AKEYCODE_LANGUAGE_SWITCH = 204,
AKEYCODE_MANNER_MODE = 205,
AKEYCODE_3D_MODE = 206,
#endif
#if __ANDROID_API__ < 15
AKEYCODE_CONTACTS = 207,
AKEYCODE_CALENDAR = 208,
AKEYCODE_MUSIC = 209,
AKEYCODE_CALCULATOR = 210,
#endif
#if __ANDROID_API__ < 16
AKEYCODE_ZENKAKU_HANKAKU = 211,
AKEYCODE_EISU = 212,
AKEYCODE_MUHENKAN = 213,
AKEYCODE_HENKAN = 214,
AKEYCODE_KATAKANA_HIRAGANA = 215,
AKEYCODE_YEN = 216,
AKEYCODE_RO = 217,
AKEYCODE_KANA = 218,
AKEYCODE_ASSIST = 219,
#endif
AMETA_FUNCTION_ON = 0x00000008,
AMETA_CTRL_ON = 0x00001000,
AMETA_CTRL_LEFT_ON = 0x00002000,
AMETA_CTRL_RIGHT_ON = 0x00004000,
AMETA_META_ON = 0x00010000,
AMETA_META_LEFT_ON = 0x00020000,
AMETA_META_RIGHT_ON = 0x00040000,
AMETA_CAPS_LOCK_ON = 0x00100000,
AMETA_NUM_LOCK_ON = 0x00200000,
AMETA_SCROLL_LOCK_ON = 0x00400000,
AMETA_ALT_MASK = AMETA_ALT_LEFT_ON | AMETA_ALT_RIGHT_ON | AMETA_ALT_ON,
AMETA_CTRL_MASK = AMETA_CTRL_LEFT_ON | AMETA_CTRL_RIGHT_ON | AMETA_CTRL_ON,
AMETA_META_MASK = AMETA_META_LEFT_ON | AMETA_META_RIGHT_ON | AMETA_META_ON,
AMETA_SHIFT_MASK = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON,
};
class AndroidMotionEvent
{
public:
enum {
ACTION_DOWN = 0,
ACTION_UP = 1,
ACTION_MOVE = 2,
ACTION_CANCEL = 3,
ACTION_OUTSIDE = 4,
ACTION_POINTER_DOWN = 5,
ACTION_POINTER_UP = 6,
ACTION_HOVER_MOVE = 7,
ACTION_HOVER_ENTER = 9,
ACTION_HOVER_EXIT = 10,
ACTION_MAGNIFY_START = 11,
ACTION_MAGNIFY = 12,
ACTION_MAGNIFY_END = 13,
EDGE_TOP = 0x00000001,
EDGE_BOTTOM = 0x00000002,
EDGE_LEFT = 0x00000004,
EDGE_RIGHT = 0x00000008,
SAMPLE_X = 0,
SAMPLE_Y = 1,
SAMPLE_PRESSURE = 2,
SAMPLE_SIZE = 3,
NUM_SAMPLE_DATA = 4,
TOOL_TYPE_UNKNOWN = 0,
TOOL_TYPE_FINGER = 1,
TOOL_TYPE_STYLUS = 2,
TOOL_TYPE_MOUSE = 3,
TOOL_TYPE_ERASER = 4,
dummy_java_enum_list_end
};
};
class nsJNIString : public nsString
{
public:
nsJNIString(jstring jstr, JNIEnv *jenv);
};
class nsJNICString : public nsCString
{
public:
nsJNICString(jstring jstr, JNIEnv *jenv);
};
}
#endif

View file

@ -1,30 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GeckoBatteryManager_h
#define GeckoBatteryManager_h
#include "GeneratedJNINatives.h"
#include "nsAppShell.h"
#include "mozilla/Hal.h"
namespace mozilla {
class GeckoBatteryManager final
: public java::GeckoBatteryManager::Natives<GeckoBatteryManager>
{
public:
static void
OnBatteryChange(double aLevel, bool aCharging, double aRemainingTime)
{
hal::NotifyBatteryChange(
hal::BatteryInformation(aLevel, aCharging, aRemainingTime));
}
};
} // namespace mozilla
#endif // GeckoBatteryManager_h

View file

@ -1,53 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GeckoNetworkManager_h
#define GeckoNetworkManager_h
#include "GeneratedJNINatives.h"
#include "nsAppShell.h"
#include "nsCOMPtr.h"
#include "nsINetworkLinkService.h"
#include "mozilla/Services.h"
namespace mozilla {
class GeckoNetworkManager final
: public java::GeckoNetworkManager::Natives<GeckoNetworkManager>
{
GeckoNetworkManager() = delete;
public:
static void
OnConnectionChanged(int32_t aType, jni::String::Param aSubType,
bool aIsWifi, int32_t aGateway)
{
hal::NotifyNetworkChange(hal::NetworkInformation(
aType, aIsWifi, aGateway));
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
os->NotifyObservers(nullptr,
NS_NETWORK_LINK_TYPE_TOPIC,
aSubType->ToString().get());
}
}
static void
OnStatusChanged(jni::String::Param aStatus)
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
os->NotifyObservers(nullptr,
NS_NETWORK_LINK_TOPIC,
aStatus->ToString().get());
}
}
};
} // namespace mozilla
#endif // GeckoNetworkManager_h

View file

@ -1,55 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GeckoScreenOrientation_h
#define GeckoScreenOrientation_h
#include "GeneratedJNINatives.h"
#include "nsAppShell.h"
#include "nsCOMPtr.h"
#include "nsIScreenManager.h"
#include "mozilla/Hal.h"
#include "mozilla/dom/ScreenOrientation.h"
namespace mozilla {
class GeckoScreenOrientation final
: public java::GeckoScreenOrientation::Natives<GeckoScreenOrientation>
{
GeckoScreenOrientation() = delete;
public:
static void
OnOrientationChange(int16_t aOrientation, int16_t aAngle)
{
nsCOMPtr<nsIScreenManager> screenMgr =
do_GetService("@mozilla.org/gfx/screenmanager;1");
nsCOMPtr<nsIScreen> screen;
if (!screenMgr || NS_FAILED(screenMgr->GetPrimaryScreen(
getter_AddRefs(screen))) || !screen) {
return;
}
nsIntRect rect;
int32_t colorDepth, pixelDepth;
if (NS_FAILED(screen->GetRect(&rect.x, &rect.y,
&rect.width, &rect.height)) ||
NS_FAILED(screen->GetColorDepth(&colorDepth)) ||
NS_FAILED(screen->GetPixelDepth(&pixelDepth))) {
return;
}
hal::NotifyScreenConfigurationChange(hal::ScreenConfiguration(
rect, static_cast<dom::ScreenOrientationInternal>(aOrientation),
aAngle, colorDepth, pixelDepth));
}
};
} // namespace mozilla
#endif // GeckoScreenOrientation_h

View file

@ -1,526 +0,0 @@
// GENERATED CODE
// Generated by the Java program at /build/annotationProcessors at compile time
// from annotations on Java methods. To update, change the annotations on the
// corresponding Java methods and rerun the build. Manually updating this file
// will cause your build to fail.
#ifndef GeneratedJNINatives_h
#define GeneratedJNINatives_h
#include "GeneratedJNIWrappers.h"
#include "mozilla/jni/Natives.h"
namespace mozilla {
namespace java {
template<class Impl>
class AlarmReceiver::Natives : public mozilla::jni::NativeImpl<AlarmReceiver, Impl>
{
public:
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod AlarmReceiver::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<AlarmReceiver::NotifyAlarmFired_t>(
mozilla::jni::NativeStub<AlarmReceiver::NotifyAlarmFired_t, Impl>
::template Wrap<&Impl::NotifyAlarmFired>)
};
template<class Impl>
class AndroidGamepadManager::Natives : public mozilla::jni::NativeImpl<AndroidGamepadManager, Impl>
{
public:
static const JNINativeMethod methods[3];
};
template<class Impl>
const JNINativeMethod AndroidGamepadManager::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<AndroidGamepadManager::OnAxisChange_t>(
mozilla::jni::NativeStub<AndroidGamepadManager::OnAxisChange_t, Impl>
::template Wrap<&Impl::OnAxisChange>),
mozilla::jni::MakeNativeMethod<AndroidGamepadManager::OnButtonChange_t>(
mozilla::jni::NativeStub<AndroidGamepadManager::OnButtonChange_t, Impl>
::template Wrap<&Impl::OnButtonChange>),
mozilla::jni::MakeNativeMethod<AndroidGamepadManager::OnGamepadChange_t>(
mozilla::jni::NativeStub<AndroidGamepadManager::OnGamepadChange_t, Impl>
::template Wrap<&Impl::OnGamepadChange>)
};
template<class Impl>
class GeckoAppShell::Natives : public mozilla::jni::NativeImpl<GeckoAppShell, Impl>
{
public:
static const JNINativeMethod methods[8];
};
template<class Impl>
const JNINativeMethod GeckoAppShell::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyObservers_t>(
mozilla::jni::NativeStub<GeckoAppShell::NotifyObservers_t, Impl>
::template Wrap<&Impl::NotifyObservers>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyAlertListener_t>(
mozilla::jni::NativeStub<GeckoAppShell::NotifyAlertListener_t, Impl>
::template Wrap<&Impl::NotifyAlertListener>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::NotifyUriVisited_t>(
mozilla::jni::NativeStub<GeckoAppShell::NotifyUriVisited_t, Impl>
::template Wrap<&Impl::NotifyUriVisited>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::OnFullScreenPluginHidden_t>(
mozilla::jni::NativeStub<GeckoAppShell::OnFullScreenPluginHidden_t, Impl>
::template Wrap<&Impl::OnFullScreenPluginHidden>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::OnLocationChanged_t>(
mozilla::jni::NativeStub<GeckoAppShell::OnLocationChanged_t, Impl>
::template Wrap<&Impl::OnLocationChanged>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::OnSensorChanged_t>(
mozilla::jni::NativeStub<GeckoAppShell::OnSensorChanged_t, Impl>
::template Wrap<&Impl::OnSensorChanged>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::ReportJavaCrash_t>(
mozilla::jni::NativeStub<GeckoAppShell::ReportJavaCrash_t, Impl>
::template Wrap<&Impl::ReportJavaCrash>),
mozilla::jni::MakeNativeMethod<GeckoAppShell::SyncNotifyObservers_t>(
mozilla::jni::NativeStub<GeckoAppShell::SyncNotifyObservers_t, Impl>
::template Wrap<&Impl::SyncNotifyObservers>)
};
template<class Impl>
class GeckoAppShell::CameraCallback::Natives : public mozilla::jni::NativeImpl<CameraCallback, Impl>
{
public:
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod GeckoAppShell::CameraCallback::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoAppShell::CameraCallback::OnFrameData_t>(
mozilla::jni::NativeStub<GeckoAppShell::CameraCallback::OnFrameData_t, Impl>
::template Wrap<&Impl::OnFrameData>)
};
template<class Impl>
class GeckoBatteryManager::Natives : public mozilla::jni::NativeImpl<GeckoBatteryManager, Impl>
{
public:
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod GeckoBatteryManager::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoBatteryManager::OnBatteryChange_t>(
mozilla::jni::NativeStub<GeckoBatteryManager::OnBatteryChange_t, Impl>
::template Wrap<&Impl::OnBatteryChange>)
};
template<class Impl>
class GeckoEditable::Natives : public mozilla::jni::NativeImpl<GeckoEditable, Impl>
{
public:
static const JNINativeMethod methods[7];
};
template<class Impl>
const JNINativeMethod GeckoEditable::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoEditable::DisposeNative_t>(
mozilla::jni::NativeStub<GeckoEditable::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>),
mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeAddCompositionRange_t>(
mozilla::jni::NativeStub<GeckoEditable::OnImeAddCompositionRange_t, Impl>
::template Wrap<&Impl::OnImeAddCompositionRange>),
mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeReplaceText_t>(
mozilla::jni::NativeStub<GeckoEditable::OnImeReplaceText_t, Impl>
::template Wrap<&Impl::OnImeReplaceText>),
mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeRequestCursorUpdates_t>(
mozilla::jni::NativeStub<GeckoEditable::OnImeRequestCursorUpdates_t, Impl>
::template Wrap<&Impl::OnImeRequestCursorUpdates>),
mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeSynchronize_t>(
mozilla::jni::NativeStub<GeckoEditable::OnImeSynchronize_t, Impl>
::template Wrap<&Impl::OnImeSynchronize>),
mozilla::jni::MakeNativeMethod<GeckoEditable::OnImeUpdateComposition_t>(
mozilla::jni::NativeStub<GeckoEditable::OnImeUpdateComposition_t, Impl>
::template Wrap<&Impl::OnImeUpdateComposition>),
mozilla::jni::MakeNativeMethod<GeckoEditable::OnKeyEvent_t>(
mozilla::jni::NativeStub<GeckoEditable::OnKeyEvent_t, Impl>
::template Wrap<&Impl::OnKeyEvent>)
};
template<class Impl>
class GeckoNetworkManager::Natives : public mozilla::jni::NativeImpl<GeckoNetworkManager, Impl>
{
public:
static const JNINativeMethod methods[2];
};
template<class Impl>
const JNINativeMethod GeckoNetworkManager::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoNetworkManager::OnConnectionChanged_t>(
mozilla::jni::NativeStub<GeckoNetworkManager::OnConnectionChanged_t, Impl>
::template Wrap<&Impl::OnConnectionChanged>),
mozilla::jni::MakeNativeMethod<GeckoNetworkManager::OnStatusChanged_t>(
mozilla::jni::NativeStub<GeckoNetworkManager::OnStatusChanged_t, Impl>
::template Wrap<&Impl::OnStatusChanged>)
};
template<class Impl>
class GeckoScreenOrientation::Natives : public mozilla::jni::NativeImpl<GeckoScreenOrientation, Impl>
{
public:
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod GeckoScreenOrientation::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoScreenOrientation::OnOrientationChange_t>(
mozilla::jni::NativeStub<GeckoScreenOrientation::OnOrientationChange_t, Impl>
::template Wrap<&Impl::OnOrientationChange>)
};
template<class Impl>
class GeckoThread::Natives : public mozilla::jni::NativeImpl<GeckoThread, Impl>
{
public:
static const JNINativeMethod methods[6];
};
template<class Impl>
const JNINativeMethod GeckoThread::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoThread::CreateServices_t>(
mozilla::jni::NativeStub<GeckoThread::CreateServices_t, Impl>
::template Wrap<&Impl::CreateServices>),
mozilla::jni::MakeNativeMethod<GeckoThread::OnPause_t>(
mozilla::jni::NativeStub<GeckoThread::OnPause_t, Impl>
::template Wrap<&Impl::OnPause>),
mozilla::jni::MakeNativeMethod<GeckoThread::OnResume_t>(
mozilla::jni::NativeStub<GeckoThread::OnResume_t, Impl>
::template Wrap<&Impl::OnResume>),
mozilla::jni::MakeNativeMethod<GeckoThread::RunUiThreadCallback_t>(
mozilla::jni::NativeStub<GeckoThread::RunUiThreadCallback_t, Impl>
::template Wrap<&Impl::RunUiThreadCallback>),
mozilla::jni::MakeNativeMethod<GeckoThread::SpeculativeConnect_t>(
mozilla::jni::NativeStub<GeckoThread::SpeculativeConnect_t, Impl>
::template Wrap<&Impl::SpeculativeConnect>),
mozilla::jni::MakeNativeMethod<GeckoThread::WaitOnGecko_t>(
mozilla::jni::NativeStub<GeckoThread::WaitOnGecko_t, Impl>
::template Wrap<&Impl::WaitOnGecko>)
};
template<class Impl>
class GeckoView::Window::Natives : public mozilla::jni::NativeImpl<Window, Impl>
{
public:
static const JNINativeMethod methods[5];
};
template<class Impl>
const JNINativeMethod GeckoView::Window::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoView::Window::Close_t>(
mozilla::jni::NativeStub<GeckoView::Window::Close_t, Impl>
::template Wrap<&Impl::Close>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::DisposeNative_t>(
mozilla::jni::NativeStub<GeckoView::Window::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::LoadUri_t>(
mozilla::jni::NativeStub<GeckoView::Window::LoadUri_t, Impl>
::template Wrap<&Impl::LoadUri>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::Open_t>(
mozilla::jni::NativeStub<GeckoView::Window::Open_t, Impl>
::template Wrap<&Impl::Open>),
mozilla::jni::MakeNativeMethod<GeckoView::Window::Reattach_t>(
mozilla::jni::NativeStub<GeckoView::Window::Reattach_t, Impl>
::template Wrap<&Impl::Reattach>)
};
template<class Impl>
class PrefsHelper::Natives : public mozilla::jni::NativeImpl<PrefsHelper, Impl>
{
public:
static const JNINativeMethod methods[4];
};
template<class Impl>
const JNINativeMethod PrefsHelper::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<PrefsHelper::AddObserver_t>(
mozilla::jni::NativeStub<PrefsHelper::AddObserver_t, Impl>
::template Wrap<&Impl::AddObserver>),
mozilla::jni::MakeNativeMethod<PrefsHelper::GetPrefs_t>(
mozilla::jni::NativeStub<PrefsHelper::GetPrefs_t, Impl>
::template Wrap<&Impl::GetPrefs>),
mozilla::jni::MakeNativeMethod<PrefsHelper::RemoveObserver_t>(
mozilla::jni::NativeStub<PrefsHelper::RemoveObserver_t, Impl>
::template Wrap<&Impl::RemoveObserver>),
mozilla::jni::MakeNativeMethod<PrefsHelper::SetPref_t>(
mozilla::jni::NativeStub<PrefsHelper::SetPref_t, Impl>
::template Wrap<&Impl::SetPref>)
};
template<class Impl>
class SurfaceTextureListener::Natives : public mozilla::jni::NativeImpl<SurfaceTextureListener, Impl>
{
public:
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod SurfaceTextureListener::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<SurfaceTextureListener::OnFrameAvailable_t>(
mozilla::jni::NativeStub<SurfaceTextureListener::OnFrameAvailable_t, Impl>
::template Wrap<&Impl::OnFrameAvailable>)
};
template<class Impl>
class LayerView::Compositor::Natives : public mozilla::jni::NativeImpl<Compositor, Impl>
{
public:
static const JNINativeMethod methods[7];
};
template<class Impl>
const JNINativeMethod LayerView::Compositor::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<LayerView::Compositor::AttachToJava_t>(
mozilla::jni::NativeStub<LayerView::Compositor::AttachToJava_t, Impl>
::template Wrap<&Impl::AttachToJava>),
mozilla::jni::MakeNativeMethod<LayerView::Compositor::CreateCompositor_t>(
mozilla::jni::NativeStub<LayerView::Compositor::CreateCompositor_t, Impl>
::template Wrap<&Impl::CreateCompositor>),
mozilla::jni::MakeNativeMethod<LayerView::Compositor::DisposeNative_t>(
mozilla::jni::NativeStub<LayerView::Compositor::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>),
mozilla::jni::MakeNativeMethod<LayerView::Compositor::OnSizeChanged_t>(
mozilla::jni::NativeStub<LayerView::Compositor::OnSizeChanged_t, Impl>
::template Wrap<&Impl::OnSizeChanged>),
mozilla::jni::MakeNativeMethod<LayerView::Compositor::SyncInvalidateAndScheduleComposite_t>(
mozilla::jni::NativeStub<LayerView::Compositor::SyncInvalidateAndScheduleComposite_t, Impl>
::template Wrap<&Impl::SyncInvalidateAndScheduleComposite>),
mozilla::jni::MakeNativeMethod<LayerView::Compositor::SyncPauseCompositor_t>(
mozilla::jni::NativeStub<LayerView::Compositor::SyncPauseCompositor_t, Impl>
::template Wrap<&Impl::SyncPauseCompositor>),
mozilla::jni::MakeNativeMethod<LayerView::Compositor::SyncResumeResizeCompositor_t>(
mozilla::jni::NativeStub<LayerView::Compositor::SyncResumeResizeCompositor_t, Impl>
::template Wrap<&Impl::SyncResumeResizeCompositor>)
};
template<class Impl>
class NativePanZoomController::Natives : public mozilla::jni::NativeImpl<NativePanZoomController, Impl>
{
public:
static const JNINativeMethod methods[7];
};
template<class Impl>
const JNINativeMethod NativePanZoomController::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<NativePanZoomController::AdjustScrollForSurfaceShift_t>(
mozilla::jni::NativeStub<NativePanZoomController::AdjustScrollForSurfaceShift_t, Impl>
::template Wrap<&Impl::AdjustScrollForSurfaceShift>),
mozilla::jni::MakeNativeMethod<NativePanZoomController::DisposeNative_t>(
mozilla::jni::NativeStub<NativePanZoomController::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>),
mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleMotionEvent_t>(
mozilla::jni::NativeStub<NativePanZoomController::HandleMotionEvent_t, Impl>
::template Wrap<&Impl::HandleMotionEvent>),
mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleMotionEventVelocity_t>(
mozilla::jni::NativeStub<NativePanZoomController::HandleMotionEventVelocity_t, Impl>
::template Wrap<&Impl::HandleMotionEventVelocity>),
mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleMouseEvent_t>(
mozilla::jni::NativeStub<NativePanZoomController::HandleMouseEvent_t, Impl>
::template Wrap<&Impl::HandleMouseEvent>),
mozilla::jni::MakeNativeMethod<NativePanZoomController::HandleScrollEvent_t>(
mozilla::jni::NativeStub<NativePanZoomController::HandleScrollEvent_t, Impl>
::template Wrap<&Impl::HandleScrollEvent>),
mozilla::jni::MakeNativeMethod<NativePanZoomController::SetIsLongpressEnabled_t>(
mozilla::jni::NativeStub<NativePanZoomController::SetIsLongpressEnabled_t, Impl>
::template Wrap<&Impl::SetIsLongpressEnabled>)
};
template<class Impl>
class NativeJSContainer::Natives : public mozilla::jni::NativeImpl<NativeJSContainer, Impl>
{
public:
static const JNINativeMethod methods[2];
};
template<class Impl>
const JNINativeMethod NativeJSContainer::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<NativeJSContainer::Clone2_t>(
mozilla::jni::NativeStub<NativeJSContainer::Clone2_t, Impl>
::template Wrap<&Impl::Clone>),
mozilla::jni::MakeNativeMethod<NativeJSContainer::DisposeNative_t>(
mozilla::jni::NativeStub<NativeJSContainer::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>)
};
template<class Impl>
class NativeJSObject::Natives : public mozilla::jni::NativeImpl<NativeJSObject, Impl>
{
public:
static const JNINativeMethod methods[27];
};
template<class Impl>
const JNINativeMethod NativeJSObject::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<NativeJSObject::GetBoolean_t>(
mozilla::jni::NativeStub<NativeJSObject::GetBoolean_t, Impl>
::template Wrap<&Impl::GetBoolean>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetBooleanArray_t>(
mozilla::jni::NativeStub<NativeJSObject::GetBooleanArray_t, Impl>
::template Wrap<&Impl::GetBooleanArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetBundle_t>(
mozilla::jni::NativeStub<NativeJSObject::GetBundle_t, Impl>
::template Wrap<&Impl::GetBundle>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetBundleArray_t>(
mozilla::jni::NativeStub<NativeJSObject::GetBundleArray_t, Impl>
::template Wrap<&Impl::GetBundleArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetDouble_t>(
mozilla::jni::NativeStub<NativeJSObject::GetDouble_t, Impl>
::template Wrap<&Impl::GetDouble>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetDoubleArray_t>(
mozilla::jni::NativeStub<NativeJSObject::GetDoubleArray_t, Impl>
::template Wrap<&Impl::GetDoubleArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetInt_t>(
mozilla::jni::NativeStub<NativeJSObject::GetInt_t, Impl>
::template Wrap<&Impl::GetInt>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetIntArray_t>(
mozilla::jni::NativeStub<NativeJSObject::GetIntArray_t, Impl>
::template Wrap<&Impl::GetIntArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetObject_t>(
mozilla::jni::NativeStub<NativeJSObject::GetObject_t, Impl>
::template Wrap<&Impl::GetObject>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetObjectArray_t>(
mozilla::jni::NativeStub<NativeJSObject::GetObjectArray_t, Impl>
::template Wrap<&Impl::GetObjectArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetString_t>(
mozilla::jni::NativeStub<NativeJSObject::GetString_t, Impl>
::template Wrap<&Impl::GetString>),
mozilla::jni::MakeNativeMethod<NativeJSObject::GetStringArray_t>(
mozilla::jni::NativeStub<NativeJSObject::GetStringArray_t, Impl>
::template Wrap<&Impl::GetStringArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::Has_t>(
mozilla::jni::NativeStub<NativeJSObject::Has_t, Impl>
::template Wrap<&Impl::Has>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptBoolean_t>(
mozilla::jni::NativeStub<NativeJSObject::OptBoolean_t, Impl>
::template Wrap<&Impl::OptBoolean>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptBooleanArray_t>(
mozilla::jni::NativeStub<NativeJSObject::OptBooleanArray_t, Impl>
::template Wrap<&Impl::OptBooleanArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptBundle_t>(
mozilla::jni::NativeStub<NativeJSObject::OptBundle_t, Impl>
::template Wrap<&Impl::OptBundle>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptBundleArray_t>(
mozilla::jni::NativeStub<NativeJSObject::OptBundleArray_t, Impl>
::template Wrap<&Impl::OptBundleArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptDouble_t>(
mozilla::jni::NativeStub<NativeJSObject::OptDouble_t, Impl>
::template Wrap<&Impl::OptDouble>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptDoubleArray_t>(
mozilla::jni::NativeStub<NativeJSObject::OptDoubleArray_t, Impl>
::template Wrap<&Impl::OptDoubleArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptInt_t>(
mozilla::jni::NativeStub<NativeJSObject::OptInt_t, Impl>
::template Wrap<&Impl::OptInt>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptIntArray_t>(
mozilla::jni::NativeStub<NativeJSObject::OptIntArray_t, Impl>
::template Wrap<&Impl::OptIntArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptObject_t>(
mozilla::jni::NativeStub<NativeJSObject::OptObject_t, Impl>
::template Wrap<&Impl::OptObject>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptObjectArray_t>(
mozilla::jni::NativeStub<NativeJSObject::OptObjectArray_t, Impl>
::template Wrap<&Impl::OptObjectArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptString_t>(
mozilla::jni::NativeStub<NativeJSObject::OptString_t, Impl>
::template Wrap<&Impl::OptString>),
mozilla::jni::MakeNativeMethod<NativeJSObject::OptStringArray_t>(
mozilla::jni::NativeStub<NativeJSObject::OptStringArray_t, Impl>
::template Wrap<&Impl::OptStringArray>),
mozilla::jni::MakeNativeMethod<NativeJSObject::ToBundle_t>(
mozilla::jni::NativeStub<NativeJSObject::ToBundle_t, Impl>
::template Wrap<&Impl::ToBundle>),
mozilla::jni::MakeNativeMethod<NativeJSObject::ToString_t>(
mozilla::jni::NativeStub<NativeJSObject::ToString_t, Impl>
::template Wrap<&Impl::ToString>)
};
} /* java */
} /* mozilla */
#endif // GeneratedJNINatives_h

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,605 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GfxInfo.h"
#include "GLContext.h"
#include "GLContextProvider.h"
#include "nsUnicharUtils.h"
#include "prenv.h"
#include "prprf.h"
#include "nsHashKeys.h"
#include "nsVersionComparator.h"
#include "AndroidBridge.h"
#include "nsIWindowWatcher.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
namespace widget {
class GfxInfo::GLStrings
{
nsCString mVendor;
nsCString mRenderer;
nsCString mVersion;
bool mReady;
public:
GLStrings()
: mReady(false)
{}
const nsCString& Vendor() {
EnsureInitialized();
return mVendor;
}
// This spoofed value wins, even if the environment variable
// MOZ_GFX_SPOOF_GL_VENDOR was set.
void SpoofVendor(const nsCString& s) {
mVendor = s;
}
const nsCString& Renderer() {
EnsureInitialized();
return mRenderer;
}
// This spoofed value wins, even if the environment variable
// MOZ_GFX_SPOOF_GL_RENDERER was set.
void SpoofRenderer(const nsCString& s) {
mRenderer = s;
}
const nsCString& Version() {
EnsureInitialized();
return mVersion;
}
// This spoofed value wins, even if the environment variable
// MOZ_GFX_SPOOF_GL_VERSION was set.
void SpoofVersion(const nsCString& s) {
mVersion = s;
}
void EnsureInitialized() {
if (mReady) {
return;
}
RefPtr<gl::GLContext> gl;
nsCString discardFailureId;
gl = gl::GLContextProvider::CreateHeadless(gl::CreateContextFlags::REQUIRE_COMPAT_PROFILE,
&discardFailureId);
if (!gl) {
// Setting mReady to true here means that we won't retry. Everything will
// remain blacklisted forever. Ideally, we would like to update that once
// any GLContext is successfully created, like the compositor's GLContext.
mReady = true;
return;
}
gl->MakeCurrent();
if (mVendor.IsEmpty()) {
const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR");
if (spoofedVendor) {
mVendor.Assign(spoofedVendor);
} else {
mVendor.Assign((const char*)gl->fGetString(LOCAL_GL_VENDOR));
}
}
if (mRenderer.IsEmpty()) {
const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER");
if (spoofedRenderer) {
mRenderer.Assign(spoofedRenderer);
} else {
mRenderer.Assign((const char*)gl->fGetString(LOCAL_GL_RENDERER));
}
}
if (mVersion.IsEmpty()) {
const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION");
if (spoofedVersion) {
mVersion.Assign(spoofedVersion);
} else {
mVersion.Assign((const char*)gl->fGetString(LOCAL_GL_VERSION));
}
}
mReady = true;
}
};
#ifdef DEBUG
NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug)
#endif
GfxInfo::GfxInfo()
: mInitialized(false)
, mGLStrings(new GLStrings)
, mOSVersionInteger(0)
, mSDKVersion(0)
{
}
GfxInfo::~GfxInfo()
{
}
/* GetD2DEnabled and GetDwriteEnabled shouldn't be called until after gfxPlatform initialization
* has occurred because they depend on it for information. (See bug 591561) */
nsresult
GfxInfo::GetD2DEnabled(bool *aEnabled)
{
return NS_ERROR_FAILURE;
}
nsresult
GfxInfo::GetDWriteEnabled(bool *aEnabled)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetDWriteVersion(nsAString & aDwriteVersion)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
{
return NS_ERROR_FAILURE;
}
void
GfxInfo::EnsureInitialized()
{
if (mInitialized)
return;
if (!mozilla::AndroidBridge::Bridge()) {
gfxWarning() << "AndroidBridge missing during initialization";
return;
}
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MODEL", mModel)) {
mAdapterDescription.AppendPrintf("Model: %s", NS_LossyConvertUTF16toASCII(mModel).get());
}
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "PRODUCT", mProduct)) {
mAdapterDescription.AppendPrintf(", Product: %s", NS_LossyConvertUTF16toASCII(mProduct).get());
}
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "MANUFACTURER", mManufacturer)) {
mAdapterDescription.AppendPrintf(", Manufacturer: %s", NS_LossyConvertUTF16toASCII(mManufacturer).get());
}
if (mozilla::AndroidBridge::Bridge()->GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &mSDKVersion)) {
// the HARDWARE field isn't available on Android SDK < 8, but we require 9+ anyway.
MOZ_ASSERT(mSDKVersion >= 8);
if (mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", mHardware)) {
mAdapterDescription.AppendPrintf(", Hardware: %s", NS_LossyConvertUTF16toASCII(mHardware).get());
}
} else {
mSDKVersion = 0;
}
nsString release;
mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", release);
mOSVersion = NS_LossyConvertUTF16toASCII(release);
mOSVersionInteger = 0;
char a[5], b[5], c[5], d[5];
SplitDriverVersion(mOSVersion.get(), a, b, c, d);
uint8_t na = atoi(a);
uint8_t nb = atoi(b);
uint8_t nc = atoi(c);
uint8_t nd = atoi(d);
mOSVersionInteger = (uint32_t(na) << 24) |
(uint32_t(nb) << 16) |
(uint32_t(nc) << 8) |
uint32_t(nd);
mAdapterDescription.AppendPrintf(", OpenGL: %s -- %s -- %s",
mGLStrings->Vendor().get(),
mGLStrings->Renderer().get(),
mGLStrings->Version().get());
AddCrashReportAnnotations();
mInitialized = true;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDescription(nsAString & aAdapterDescription)
{
EnsureInitialized();
aAdapterDescription = NS_ConvertASCIItoUTF16(mAdapterDescription);
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM)
{
EnsureInitialized();
aAdapterRAM.Truncate();
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver)
{
EnsureInitialized();
aAdapterDriver.Truncate();
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)
{
EnsureInitialized();
aAdapterDriverVersion = NS_ConvertASCIItoUTF16(mGLStrings->Version());
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDriverDate(nsAString & aAdapterDriverDate)
{
EnsureInitialized();
aAdapterDriverDate.Truncate();
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterVendorID(nsAString & aAdapterVendorID)
{
EnsureInitialized();
aAdapterVendorID = NS_ConvertASCIItoUTF16(mGLStrings->Vendor());
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterVendorID2(nsAString & aAdapterVendorID)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDeviceID(nsAString & aAdapterDeviceID)
{
EnsureInitialized();
aAdapterDeviceID = NS_ConvertASCIItoUTF16(mGLStrings->Renderer());
return NS_OK;
}
NS_IMETHODIMP
GfxInfo::GetAdapterDeviceID2(nsAString & aAdapterDeviceID)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterSubsysID(nsAString & aAdapterSubsysID)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetAdapterSubsysID2(nsAString & aAdapterSubsysID)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active)
{
EnsureInitialized();
return NS_ERROR_FAILURE;
}
void
GfxInfo::AddCrashReportAnnotations()
{
/*** STUB ***/
}
const nsTArray<GfxDriverInfo>&
GfxInfo::GetGfxDriverInfo()
{
if (mDriverInfo->IsEmpty()) {
APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Android,
(nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices,
nsIGfxInfo::FEATURE_OPENGL_LAYERS, nsIGfxInfo::FEATURE_STATUS_OK,
DRIVER_COMPARISON_IGNORED, GfxDriverInfo::allDriverVersions,
"FEATURE_OK_FORCE_OPENGL" );
}
return *mDriverInfo;
}
nsresult
GfxInfo::GetFeatureStatusImpl(int32_t aFeature,
int32_t *aStatus,
nsAString &aSuggestedDriverVersion,
const nsTArray<GfxDriverInfo>& aDriverInfo,
nsACString &aFailureId,
OperatingSystem* aOS /* = nullptr */)
{
NS_ENSURE_ARG_POINTER(aStatus);
aSuggestedDriverVersion.SetIsVoid(true);
*aStatus = nsIGfxInfo::FEATURE_STATUS_UNKNOWN;
OperatingSystem os = mOS;
if (aOS)
*aOS = os;
if (mShutdownOccurred) {
return NS_OK;
}
// OpenGL layers are never blacklisted on Android.
// This early return is so we avoid potentially slow
// GLStrings initialization on startup when we initialize GL layers.
if (aFeature == nsIGfxInfo::FEATURE_OPENGL_LAYERS) {
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
return NS_OK;
}
EnsureInitialized();
if (mGLStrings->Vendor().IsEmpty() || mGLStrings->Renderer().IsEmpty()) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
return NS_OK;
}
// Don't evaluate special cases when evaluating the downloaded blocklist.
if (aDriverInfo.IsEmpty()) {
if (aFeature == nsIGfxInfo::FEATURE_CANVAS2D_ACCELERATION) {
if (mSDKVersion < 11) {
// It's slower than software due to not having a compositing fast path
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_OS_VERSION;
aFailureId = "FEATURE_FAILURE_CANVAS_2D_SDK";
} else if (mGLStrings->Renderer().Find("Vivante GC1000") != -1) {
// Blocklist Vivante GC1000. See bug 1248183.
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILED_CANVAS_2D_HW";
} else {
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
}
return NS_OK;
}
if (aFeature == FEATURE_WEBGL_OPENGL) {
if (mGLStrings->Renderer().Find("Adreno 200") != -1 ||
mGLStrings->Renderer().Find("Adreno 205") != -1)
{
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_ADRENO_20x";
return NS_OK;
}
if (mHardware.EqualsLiteral("ville")) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_VILLE";
return NS_OK;
}
}
if (aFeature == FEATURE_STAGEFRIGHT) {
NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
NS_LossyConvertUTF16toASCII cModel(mModel);
NS_LossyConvertUTF16toASCII cHardware(mHardware);
if (cHardware.EqualsLiteral("antares") ||
cHardware.EqualsLiteral("harmony") ||
cHardware.EqualsLiteral("picasso") ||
cHardware.EqualsLiteral("picasso_e") ||
cHardware.EqualsLiteral("ventana") ||
cHardware.EqualsLiteral("rk30board"))
{
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_STAGE_HW";
return NS_OK;
}
if (CompareVersions(mOSVersion.get(), "4.1.0") < 0)
{
// Whitelist:
// All Samsung ICS devices, except for:
// Samsung SGH-I717 (Bug 845729)
// Samsung SGH-I727 (Bug 845729)
// Samsung SGH-I757 (Bug 845729)
// All Galaxy nexus ICS devices
// Sony Xperia Ion (LT28) ICS devices
bool isWhitelisted =
cModel.Equals("LT28h", nsCaseInsensitiveCStringComparator()) ||
cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator()) ||
cModel.Equals("galaxy nexus", nsCaseInsensitiveCStringComparator()); // some Galaxy Nexus have manufacturer=amazon
if (cModel.Find("SGH-I717", true) != -1 ||
cModel.Find("SGH-I727", true) != -1 ||
cModel.Find("SGH-I757", true) != -1)
{
isWhitelisted = false;
}
if (!isWhitelisted) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_4_1_HW";
return NS_OK;
}
}
else if (CompareVersions(mOSVersion.get(), "4.2.0") < 0)
{
// Whitelist:
// All JB phones except for those in blocklist below
// Blocklist:
// Samsung devices from bug 812881 and 853522.
// Motorola XT890 from bug 882342.
bool isBlocklisted =
cModel.Find("GT-P3100", true) != -1 ||
cModel.Find("GT-P3110", true) != -1 ||
cModel.Find("GT-P3113", true) != -1 ||
cModel.Find("GT-P5100", true) != -1 ||
cModel.Find("GT-P5110", true) != -1 ||
cModel.Find("GT-P5113", true) != -1 ||
cModel.Find("XT890", true) != -1;
if (isBlocklisted) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_4_2_HW";
return NS_OK;
}
}
else if (CompareVersions(mOSVersion.get(), "4.3.0") < 0)
{
// Blocklist all Sony devices
if (cManufacturer.Find("Sony", true) != -1) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_4_3_SONY";
return NS_OK;
}
}
}
if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_ENCODE) {
if (mozilla::AndroidBridge::Bridge()) {
*aStatus = mozilla::AndroidBridge::Bridge()->GetHWEncoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_WEBRTC_ENCODE";
return NS_OK;
}
}
if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION_DECODE) {
if (mozilla::AndroidBridge::Bridge()) {
*aStatus = mozilla::AndroidBridge::Bridge()->GetHWDecoderCapability() ? nsIGfxInfo::FEATURE_STATUS_OK : nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_WEBRTC_DECODE";
return NS_OK;
}
}
if (aFeature == FEATURE_VP8_HW_DECODE || aFeature == FEATURE_VP9_HW_DECODE) {
NS_LossyConvertUTF16toASCII model(mModel);
bool isBlocked =
// GIFV crash, see bug 1232911.
model.Equals("GT-N8013", nsCaseInsensitiveCStringComparator());
if (isBlocked) {
*aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
aFailureId = "FEATURE_FAILURE_VPx";
} else {
*aStatus = nsIGfxInfo::FEATURE_STATUS_OK;
}
return NS_OK;
}
}
return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, aFailureId, &os);
}
#ifdef DEBUG
// Implement nsIGfxInfoDebug
NS_IMETHODIMP GfxInfo::SpoofVendorID(const nsAString & aVendorID)
{
mGLStrings->SpoofVendor(NS_LossyConvertUTF16toASCII(aVendorID));
return NS_OK;
}
NS_IMETHODIMP GfxInfo::SpoofDeviceID(const nsAString & aDeviceID)
{
mGLStrings->SpoofRenderer(NS_LossyConvertUTF16toASCII(aDeviceID));
return NS_OK;
}
NS_IMETHODIMP GfxInfo::SpoofDriverVersion(const nsAString & aDriverVersion)
{
mGLStrings->SpoofVersion(NS_LossyConvertUTF16toASCII(aDriverVersion));
return NS_OK;
}
NS_IMETHODIMP GfxInfo::SpoofOSVersion(uint32_t aVersion)
{
EnsureInitialized();
mOSVersion = aVersion;
return NS_OK;
}
#endif
nsString GfxInfo::Model()
{
EnsureInitialized();
return mModel;
}
nsString GfxInfo::Hardware()
{
EnsureInitialized();
return mHardware;
}
nsString GfxInfo::Product()
{
EnsureInitialized();
return mProduct;
}
nsString GfxInfo::Manufacturer()
{
EnsureInitialized();
return mManufacturer;
}
uint32_t GfxInfo::OperatingSystemVersion()
{
EnsureInitialized();
return mOSVersionInteger;
}
}
}

View file

@ -1,102 +0,0 @@
/* vim: se cin sw=2 ts=2 et : */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __mozilla_widget_GfxInfo_h__
#define __mozilla_widget_GfxInfo_h__
#include "GfxInfoBase.h"
#include "GfxDriverInfo.h"
#include "nsString.h"
#include "mozilla/UniquePtr.h"
namespace mozilla {
namespace widget {
class GfxInfo : public GfxInfoBase
{
private:
~GfxInfo();
public:
GfxInfo();
// We only declare the subset of nsIGfxInfo that we actually implement. The
// rest is brought forward from GfxInfoBase.
NS_IMETHOD GetD2DEnabled(bool *aD2DEnabled) override;
NS_IMETHOD GetDWriteEnabled(bool *aDWriteEnabled) override;
NS_IMETHOD GetDWriteVersion(nsAString & aDwriteVersion) override;
NS_IMETHOD GetCleartypeParameters(nsAString & aCleartypeParams) override;
NS_IMETHOD GetAdapterDescription(nsAString & aAdapterDescription) override;
NS_IMETHOD GetAdapterDriver(nsAString & aAdapterDriver) override;
NS_IMETHOD GetAdapterVendorID(nsAString & aAdapterVendorID) override;
NS_IMETHOD GetAdapterDeviceID(nsAString & aAdapterDeviceID) override;
NS_IMETHOD GetAdapterSubsysID(nsAString & aAdapterSubsysID) override;
NS_IMETHOD GetAdapterRAM(nsAString & aAdapterRAM) override;
NS_IMETHOD GetAdapterDriverVersion(nsAString & aAdapterDriverVersion) override;
NS_IMETHOD GetAdapterDriverDate(nsAString & aAdapterDriverDate) override;
NS_IMETHOD GetAdapterDescription2(nsAString & aAdapterDescription) override;
NS_IMETHOD GetAdapterDriver2(nsAString & aAdapterDriver) override;
NS_IMETHOD GetAdapterVendorID2(nsAString & aAdapterVendorID) override;
NS_IMETHOD GetAdapterDeviceID2(nsAString & aAdapterDeviceID) override;
NS_IMETHOD GetAdapterSubsysID2(nsAString & aAdapterSubsysID) override;
NS_IMETHOD GetAdapterRAM2(nsAString & aAdapterRAM) override;
NS_IMETHOD GetAdapterDriverVersion2(nsAString & aAdapterDriverVersion) override;
NS_IMETHOD GetAdapterDriverDate2(nsAString & aAdapterDriverDate) override;
NS_IMETHOD GetIsGPU2Active(bool *aIsGPU2Active) override;
using GfxInfoBase::GetFeatureStatus;
using GfxInfoBase::GetFeatureSuggestedDriverVersion;
using GfxInfoBase::GetWebGLParameter;
void EnsureInitialized();
virtual nsString Model() override;
virtual nsString Hardware() override;
virtual nsString Product() override;
virtual nsString Manufacturer() override;
#ifdef DEBUG
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIGFXINFODEBUG
#endif
virtual uint32_t OperatingSystemVersion() override;
protected:
virtual nsresult GetFeatureStatusImpl(int32_t aFeature,
int32_t *aStatus,
nsAString & aSuggestedDriverVersion,
const nsTArray<GfxDriverInfo>& aDriverInfo,
nsACString &aFailureId,
OperatingSystem* aOS = nullptr) override;
virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() override;
private:
void AddCrashReportAnnotations();
bool mInitialized;
class GLStrings;
UniquePtr<GLStrings> mGLStrings;
nsCString mAdapterDescription;
OperatingSystem mOS;
nsString mModel, mHardware, mManufacturer, mProduct;
nsCString mOSVersion;
uint32_t mOSVersionInteger;
int32_t mSDKVersion;
};
} // namespace widget
} // namespace mozilla
#endif /* __mozilla_widget_GfxInfo_h__ */

View file

@ -1,881 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "NativeJSContainer.h"
#include <jni.h>
#include "Bundle.h"
#include "GeneratedJNINatives.h"
#include "MainThreadUtils.h"
#include "jsapi.h"
#include "nsJSUtils.h"
#include <mozilla/Vector.h>
#include <mozilla/jni/Accessors.h>
#include <mozilla/jni/Refs.h>
#include <mozilla/jni/Utils.h>
/**
* NativeJSContainer.cpp implements the native methods in both
* NativeJSContainer and NativeJSObject, using JSAPI to retrieve values from a
* JSObject and using JNI to return those values to Java code.
*/
namespace mozilla {
namespace widget {
namespace {
bool CheckThread()
{
if (!NS_IsMainThread()) {
jni::ThrowException("java/lang/IllegalThreadStateException",
"Not on Gecko thread");
return false;
}
return true;
}
template<class C, typename T> bool
CheckJNIArgument(const jni::Ref<C, T>& arg)
{
if (!arg) {
jni::ThrowException("java/lang/IllegalArgumentException",
"Null argument");
}
return !!arg;
}
nsresult
CheckSDKCall(nsresult rv)
{
if (NS_FAILED(rv)) {
jni::ThrowException("java/lang/UnsupportedOperationException",
"SDK JNI call failed");
}
return rv;
}
// Convert a JNI string to a char16_t string that JSAPI expects.
class JSJNIString final
{
JNIEnv* const mEnv;
jni::String::Param mJNIString;
const char16_t* const mJSString;
public:
JSJNIString(JNIEnv* env, jni::String::Param str)
: mEnv(env)
, mJNIString(str)
, mJSString(!str ? nullptr : reinterpret_cast<const char16_t*>(
mEnv->GetStringChars(str.Get(), nullptr)))
{}
~JSJNIString() {
if (mJNIString) {
mEnv->ReleaseStringChars(mJNIString.Get(),
reinterpret_cast<const jchar*>(mJSString));
}
}
operator const char16_t*() const {
return mJSString;
}
size_t Length() const {
return static_cast<size_t>(mEnv->GetStringLength(mJNIString.Get()));
}
};
} // namepsace
class NativeJSContainerImpl final
: public NativeJSObject::Natives<NativeJSContainerImpl>
, public NativeJSContainer::Natives<NativeJSContainerImpl>
{
typedef NativeJSContainerImpl Self;
typedef NativeJSContainer::Natives<NativeJSContainerImpl> ContainerBase;
typedef NativeJSObject::Natives<NativeJSContainerImpl> ObjectBase;
typedef JS::PersistentRooted<JSObject*> PersistentObject;
JNIEnv* const mEnv;
// Context that the object is valid in
JSContext* const mJSContext;
// Root JS object
PersistentObject mJSObject;
// Children objects
Vector<NativeJSObject::GlobalRef, 0> mChildren;
bool CheckObject() const
{
if (!mJSObject) {
jni::ThrowException("java/lang/NullPointerException",
"Null JSObject");
}
return !!mJSObject;
}
bool CheckJSCall(bool result) const
{
if (!result) {
JS_ClearPendingException(mJSContext);
jni::ThrowException("java/lang/UnsupportedOperationException",
"JSAPI call failed");
}
return result;
}
// Check that a JS Value contains a particular property type as indicaed by
// the property's InValue method (e.g. StringProperty::InValue).
bool CheckProperty(bool (Self::*InValue)(JS::HandleValue) const,
JS::HandleValue val) const
{
if (!(this->*InValue)(val)) {
// XXX this can happen when converting a double array inside a
// Bundle, because double arrays can be misidentified as an int
// array. The workaround is to add a dummy first element to the
// array that is a floating point value, i.e. [0.5, ...].
jni::ThrowException(
"org/mozilla/gecko/util/NativeJSObject$InvalidPropertyException",
"Property type mismatch");
return false;
}
return true;
}
// Primitive properties
template<bool (JS::Value::*IsType)() const> bool
PrimitiveInValue(JS::HandleValue val) const
{
return (static_cast<const JS::Value&>(val).*IsType)();
}
template<typename U, U (JS::Value::*ToType)() const> U
PrimitiveFromValue(JS::HandleValue val) const
{
return (static_cast<const JS::Value&>(val).*ToType)();
}
template<class Prop> typename Prop::NativeArray
PrimitiveNewArray(JS::HandleObject array, size_t length) const
{
typedef typename Prop::JNIType JNIType;
// Fill up a temporary buffer for our array, then use
// JNIEnv::Set*ArrayRegion to fill out array in one go.
UniquePtr<JNIType[]> buffer = MakeUnique<JNIType[]>(length);
for (size_t i = 0; i < length; i++) {
JS::RootedValue elem(mJSContext);
if (!CheckJSCall(JS_GetElement(mJSContext, array, i, &elem)) ||
!CheckProperty(Prop::InValue, elem)) {
return nullptr;
}
buffer[i] = JNIType((this->*Prop::FromValue)(elem));
}
auto jarray = Prop::NativeArray::Adopt(
mEnv, (mEnv->*Prop::NewJNIArray)(length));
if (!jarray) {
return nullptr;
}
(mEnv->*Prop::SetJNIArrayRegion)(
jarray.Get(), 0, length, buffer.get());
if (mEnv->ExceptionCheck()) {
return nullptr;
}
return jarray;
}
template<typename U, typename UA, typename V, typename VA,
bool (JS::Value::*IsType)() const,
U (JS::Value::*ToType)() const,
VA (JNIEnv::*NewArray_)(jsize),
void (JNIEnv::*SetArrayRegion_)(VA, jsize, jsize, const V*)>
struct PrimitiveProperty
{
// C++ type for a primitive property (e.g. bool)
typedef U NativeType;
// C++ type for the fallback value used in opt* methods
typedef U NativeFallback;
// Type for an array of the primitive type (e.g. BooleanArray::LocalRef)
typedef typename UA::LocalRef NativeArray;
// Type for the fallback value used in opt*Array methods
typedef const typename UA::Ref ArrayFallback;
// JNI type (e.g. jboolean)
typedef V JNIType;
// JNIEnv function to create a new JNI array of the primiive type
typedef decltype(NewArray_) NewJNIArray_t;
static constexpr NewJNIArray_t NewJNIArray = NewArray_;
// JNIEnv function to fill a JNI array of the primiive type
typedef decltype(SetArrayRegion_) SetJNIArrayRegion_t;
static constexpr SetJNIArrayRegion_t SetJNIArrayRegion = SetArrayRegion_;
// Function to determine if a JS Value contains the primitive type
typedef decltype(&Self::PrimitiveInValue<IsType>) InValue_t;
static constexpr InValue_t InValue = &Self::PrimitiveInValue<IsType>;
// Function to convert a JS Value to the primitive type
typedef decltype(&Self::PrimitiveFromValue<U, ToType>) FromValue_t;
static constexpr FromValue_t FromValue
= &Self::PrimitiveFromValue<U, ToType>;
// Function to convert a JS array to a JNI array
typedef decltype(&Self::PrimitiveNewArray<PrimitiveProperty>) NewArray_t;
static constexpr NewArray_t NewArray
= &Self::PrimitiveNewArray<PrimitiveProperty>;
};
// String properties
bool StringInValue(JS::HandleValue val) const
{
return val.isString();
}
jni::String::LocalRef
StringFromValue(const JS::HandleString str) const
{
nsAutoJSString autoStr;
if (!CheckJSCall(autoStr.init(mJSContext, str))) {
return nullptr;
}
// StringParam can automatically convert a nsString to jstring.
return jni::StringParam(autoStr, mEnv);
}
jni::String::LocalRef
StringFromValue(JS::HandleValue val)
{
const JS::RootedString str(mJSContext, val.toString());
return StringFromValue(str);
}
// Bundle properties
sdk::Bundle::LocalRef
BundleFromValue(const JS::HandleObject obj)
{
JS::Rooted<JS::IdVector> ids(mJSContext, JS::IdVector(mJSContext));
if (!CheckJSCall(JS_Enumerate(mJSContext, obj, &ids))) {
return nullptr;
}
const size_t length = ids.length();
sdk::Bundle::LocalRef newBundle(mEnv);
NS_ENSURE_SUCCESS(CheckSDKCall(
sdk::Bundle::New(length, &newBundle)), nullptr);
// Iterate through each property of the JS object. For each property,
// determine its type from a list of supported types, and convert that
// proeprty to the supported type.
for (size_t i = 0; i < ids.length(); i++) {
const JS::RootedId id(mJSContext, ids[i]);
JS::RootedValue idVal(mJSContext);
if (!CheckJSCall(JS_IdToValue(mJSContext, id, &idVal))) {
return nullptr;
}
const JS::RootedString idStr(mJSContext,
JS::ToString(mJSContext, idVal));
if (!CheckJSCall(!!idStr)) {
return nullptr;
}
jni::String::LocalRef name = StringFromValue(idStr);
JS::RootedValue val(mJSContext);
if (!name ||
!CheckJSCall(JS_GetPropertyById(mJSContext, obj, id, &val))) {
return nullptr;
}
#define PUT_IN_BUNDLE_IF_TYPE_IS(TYPE) \
if ((this->*TYPE##Property::InValue)(val)) { \
auto jval = (this->*TYPE##Property::FromValue)(val); \
if (mEnv->ExceptionCheck()) { \
return nullptr; \
} \
NS_ENSURE_SUCCESS(CheckSDKCall( \
newBundle->Put##TYPE(name, jval)), nullptr); \
continue; \
} \
((void) 0) // Accommodate trailing semicolon.
// Scalar values are faster to check, so check them first.
PUT_IN_BUNDLE_IF_TYPE_IS(Boolean);
// Int can be casted to double, so check int first.
PUT_IN_BUNDLE_IF_TYPE_IS(Int);
PUT_IN_BUNDLE_IF_TYPE_IS(Double);
PUT_IN_BUNDLE_IF_TYPE_IS(String);
// There's no "putObject", so don't check ObjectProperty
// Check for array types if scalar checks all failed.
// XXX empty arrays are treated as boolean arrays. Workaround is
// to always have a dummy element to create a non-empty array.
PUT_IN_BUNDLE_IF_TYPE_IS(BooleanArray);
// XXX because we only check the first element of an array,
// a double array can potentially be seen as an int array.
// When that happens, the Bundle conversion will fail.
PUT_IN_BUNDLE_IF_TYPE_IS(IntArray);
PUT_IN_BUNDLE_IF_TYPE_IS(DoubleArray);
PUT_IN_BUNDLE_IF_TYPE_IS(StringArray);
// There's no "putObjectArray", so don't check ObjectArrayProperty
// There's no "putBundleArray", so don't check BundleArrayProperty
// Use Bundle as the default catch-all for objects
PUT_IN_BUNDLE_IF_TYPE_IS(Bundle);
#undef PUT_IN_BUNDLE_IF_TYPE_IS
// We tried all supported types; just bail.
jni::ThrowException("java/lang/UnsupportedOperationException",
"Unsupported property type");
return nullptr;
}
return jni::Object::LocalRef::Adopt(newBundle.Env(),
newBundle.Forget());
}
sdk::Bundle::LocalRef
BundleFromValue(JS::HandleValue val)
{
if (val.isNull()) {
return nullptr;
}
JS::RootedObject object(mJSContext, &val.toObject());
return BundleFromValue(object);
}
// Object properties
bool ObjectInValue(JS::HandleValue val) const
{
return val.isObjectOrNull();
}
NativeJSObject::LocalRef
ObjectFromValue(JS::HandleValue val)
{
if (val.isNull()) {
return nullptr;
}
JS::RootedObject object(mJSContext, &val.toObject());
return CreateChild(object);
}
template<class Prop> typename Prop::NativeArray
ObjectNewArray(JS::HandleObject array, size_t length)
{
auto jarray = Prop::NativeArray::Adopt(mEnv, mEnv->NewObjectArray(
length, typename Prop::ClassType::Context().ClassRef(),
nullptr));
if (!jarray) {
return nullptr;
}
// For object arrays, we have to set each element separately.
for (size_t i = 0; i < length; i++) {
JS::RootedValue elem(mJSContext);
if (!CheckJSCall(JS_GetElement(mJSContext, array, i, &elem)) ||
!CheckProperty(Prop::InValue, elem)) {
return nullptr;
}
mEnv->SetObjectArrayElement(
jarray.Get(), i, (this->*Prop::FromValue)(elem).Get());
if (mEnv->ExceptionCheck()) {
return nullptr;
}
}
return jarray;
}
template<class Class,
bool (Self::*InValue_)(JS::HandleValue) const,
typename Class::LocalRef (Self::*FromValue_)(JS::HandleValue)>
struct BaseObjectProperty
{
// JNI class for the object type (e.g. jni::String)
typedef Class ClassType;
// See comments in PrimitiveProperty.
typedef typename ClassType::LocalRef NativeType;
typedef const typename ClassType::Ref NativeFallback;
typedef typename jni::ObjectArray::LocalRef NativeArray;
typedef const jni::ObjectArray::Ref ArrayFallback;
typedef decltype(InValue_) InValue_t;
static constexpr InValue_t InValue = InValue_;
typedef decltype(FromValue_) FromValue_t;
static constexpr FromValue_t FromValue = FromValue_;
typedef decltype(&Self::ObjectNewArray<BaseObjectProperty>) NewArray_t;
static constexpr NewArray_t NewArray
= &Self::ObjectNewArray<BaseObjectProperty>;
};
// Array properties
template<class Prop> bool
ArrayInValue(JS::HandleValue val) const
{
if (!val.isObject()) {
return false;
}
JS::RootedObject obj(mJSContext, &val.toObject());
bool isArray;
uint32_t length = 0;
if (!JS_IsArrayObject(mJSContext, obj, &isArray) ||
!isArray ||
!JS_GetArrayLength(mJSContext, obj, &length)) {
JS_ClearPendingException(mJSContext);
return false;
}
if (!length) {
// Empty arrays are always okay.
return true;
}
// We only check to see the first element is the target type. If the
// array has mixed types, we'll throw an error during actual conversion.
JS::RootedValue element(mJSContext);
if (!JS_GetElement(mJSContext, obj, 0, &element)) {
JS_ClearPendingException(mJSContext);
return false;
}
return (this->*Prop::InValue)(element);
}
template<class Prop> typename Prop::NativeArray
ArrayFromValue(JS::HandleValue val)
{
JS::RootedObject obj(mJSContext, &val.toObject());
uint32_t length = 0;
if (!CheckJSCall(JS_GetArrayLength(mJSContext, obj, &length))) {
return nullptr;
}
return (this->*Prop::NewArray)(obj, length);
}
template<class Prop>
struct ArrayProperty
{
// See comments in PrimitiveProperty.
typedef typename Prop::NativeArray NativeType;
typedef typename Prop::ArrayFallback NativeFallback;
typedef decltype(&Self::ArrayInValue<Prop>) InValue_t;
static constexpr InValue_t InValue
= &Self::ArrayInValue<Prop>;
typedef decltype(&Self::ArrayFromValue<Prop>) FromValue_t;
static constexpr FromValue_t FromValue
= &Self::ArrayFromValue<Prop>;
};
// "Has" property is a special property type that is used to implement
// NativeJSObject.has, by returning true from InValue and FromValue for
// every existing property, and having false as the fallback value for
// when a property doesn't exist.
bool HasValue(JS::HandleValue val) const
{
return true;
}
struct HasProperty
{
// See comments in PrimitiveProperty.
typedef bool NativeType;
typedef bool NativeFallback;
typedef decltype(&Self::HasValue) HasValue_t;
static constexpr HasValue_t InValue = &Self::HasValue;
static constexpr HasValue_t FromValue = &Self::HasValue;
};
// Statically cast from bool to jboolean (unsigned char); it works
// since false and JNI_FALSE have the same value (0), and true and
// JNI_TRUE have the same value (1).
typedef PrimitiveProperty<
bool, jni::BooleanArray, jboolean, jbooleanArray,
&JS::Value::isBoolean, &JS::Value::toBoolean,
&JNIEnv::NewBooleanArray, &JNIEnv::SetBooleanArrayRegion>
BooleanProperty;
typedef PrimitiveProperty<
double, jni::DoubleArray, jdouble, jdoubleArray,
&JS::Value::isNumber, &JS::Value::toNumber,
&JNIEnv::NewDoubleArray, &JNIEnv::SetDoubleArrayRegion>
DoubleProperty;
typedef PrimitiveProperty<
int32_t, jni::IntArray, jint, jintArray,
&JS::Value::isInt32, &JS::Value::toInt32,
&JNIEnv::NewIntArray, &JNIEnv::SetIntArrayRegion>
IntProperty;
typedef BaseObjectProperty<
jni::String, &Self::StringInValue, &Self::StringFromValue>
StringProperty;
typedef BaseObjectProperty<
sdk::Bundle, &Self::ObjectInValue, &Self::BundleFromValue>
BundleProperty;
typedef BaseObjectProperty<
NativeJSObject, &Self::ObjectInValue, &Self::ObjectFromValue>
ObjectProperty;
typedef ArrayProperty<BooleanProperty> BooleanArrayProperty;
typedef ArrayProperty<DoubleProperty> DoubleArrayProperty;
typedef ArrayProperty<IntProperty> IntArrayProperty;
typedef ArrayProperty<StringProperty> StringArrayProperty;
typedef ArrayProperty<BundleProperty> BundleArrayProperty;
typedef ArrayProperty<ObjectProperty> ObjectArrayProperty;
template<class Prop>
typename Prop::NativeType
GetProperty(jni::String::Param name,
typename Prop::NativeFallback* fallback = nullptr)
{
if (!CheckThread() || !CheckObject()) {
return typename Prop::NativeType();
}
const JSJNIString nameStr(mEnv, name);
JS::RootedValue val(mJSContext);
if (!CheckJNIArgument(name) ||
!CheckJSCall(JS_GetUCProperty(
mJSContext, mJSObject, nameStr, nameStr.Length(), &val))) {
return typename Prop::NativeType();
}
// Strictly, null is different from undefined in JS. However, in
// practice, null is often used to indicate a property doesn't exist in
// the same manner as undefined. Therefore, we treat null in the same
// way as undefined when checking property existence (bug 1014965).
if (val.isUndefined() || val.isNull()) {
if (fallback) {
return mozilla::Move(*fallback);
}
jni::ThrowException(
"org/mozilla/gecko/util/NativeJSObject$InvalidPropertyException",
"Property does not exist");
return typename Prop::NativeType();
}
if (!CheckProperty(Prop::InValue, val)) {
return typename Prop::NativeType();
}
return (this->*Prop::FromValue)(val);
}
NativeJSObject::LocalRef CreateChild(JS::HandleObject object)
{
auto instance = NativeJSObject::New();
mozilla::UniquePtr<NativeJSContainerImpl> impl(
new NativeJSContainerImpl(instance.Env(), mJSContext, object));
ObjectBase::AttachNative(instance, mozilla::Move(impl));
if (!mChildren.append(NativeJSObject::GlobalRef(instance))) {
MOZ_CRASH();
}
return instance;
}
NativeJSContainerImpl(JNIEnv* env, JSContext* cx, JS::HandleObject object)
: mEnv(env)
, mJSContext(cx)
, mJSObject(cx, object)
{}
public:
~NativeJSContainerImpl()
{
// Dispose of all children on destruction. The children will in turn
// dispose any of their children (i.e. our grandchildren) and so on.
NativeJSObject::LocalRef child(mEnv);
for (size_t i = 0; i < mChildren.length(); i++) {
child = mChildren[i];
ObjectBase::GetNative(child)->ObjectBase::DisposeNative(child);
}
}
static NativeJSContainer::LocalRef
CreateInstance(JSContext* cx, JS::HandleObject object)
{
auto instance = NativeJSContainer::New();
mozilla::UniquePtr<NativeJSContainerImpl> impl(
new NativeJSContainerImpl(instance.Env(), cx, object));
ContainerBase::AttachNative(instance, mozilla::Move(impl));
return instance;
}
// NativeJSContainer methods
void DisposeNative(const NativeJSContainer::LocalRef& instance)
{
if (!CheckThread()) {
return;
}
ContainerBase::DisposeNative(instance);
}
NativeJSContainer::LocalRef Clone()
{
if (!CheckThread()) {
return nullptr;
}
return CreateInstance(mJSContext, mJSObject);
}
// NativeJSObject methods
bool GetBoolean(jni::String::Param name)
{
return GetProperty<BooleanProperty>(name);
}
bool OptBoolean(jni::String::Param name, bool fallback)
{
return GetProperty<BooleanProperty>(name, &fallback);
}
jni::BooleanArray::LocalRef
GetBooleanArray(jni::String::Param name)
{
return GetProperty<BooleanArrayProperty>(name);
}
jni::BooleanArray::LocalRef
OptBooleanArray(jni::String::Param name, jni::BooleanArray::Param fallback)
{
return GetProperty<BooleanArrayProperty>(name, &fallback);
}
jni::Object::LocalRef
GetBundle(jni::String::Param name)
{
return GetProperty<BundleProperty>(name);
}
jni::Object::LocalRef
OptBundle(jni::String::Param name, jni::Object::Param fallback)
{
// Because the GetProperty expects a sdk::Bundle::Param,
// we have to do conversions here from jni::Object::Param.
const auto& fb = sdk::Bundle::Ref::From(fallback.Get());
return GetProperty<BundleProperty>(name, &fb);
}
jni::ObjectArray::LocalRef
GetBundleArray(jni::String::Param name)
{
return GetProperty<BundleArrayProperty>(name);
}
jni::ObjectArray::LocalRef
OptBundleArray(jni::String::Param name, jni::ObjectArray::Param fallback)
{
return GetProperty<BundleArrayProperty>(name, &fallback);
}
double GetDouble(jni::String::Param name)
{
return GetProperty<DoubleProperty>(name);
}
double OptDouble(jni::String::Param name, double fallback)
{
return GetProperty<DoubleProperty>(name, &fallback);
}
jni::DoubleArray::LocalRef
GetDoubleArray(jni::String::Param name)
{
return GetProperty<DoubleArrayProperty>(name);
}
jni::DoubleArray::LocalRef
OptDoubleArray(jni::String::Param name, jni::DoubleArray::Param fallback)
{
jni::DoubleArray::LocalRef fb(fallback);
return GetProperty<DoubleArrayProperty>(name, &fb);
}
int GetInt(jni::String::Param name)
{
return GetProperty<IntProperty>(name);
}
int OptInt(jni::String::Param name, int fallback)
{
return GetProperty<IntProperty>(name, &fallback);
}
jni::IntArray::LocalRef
GetIntArray(jni::String::Param name)
{
return GetProperty<IntArrayProperty>(name);
}
jni::IntArray::LocalRef
OptIntArray(jni::String::Param name, jni::IntArray::Param fallback)
{
jni::IntArray::LocalRef fb(fallback);
return GetProperty<IntArrayProperty>(name, &fb);
}
NativeJSObject::LocalRef
GetObject(jni::String::Param name)
{
return GetProperty<ObjectProperty>(name);
}
NativeJSObject::LocalRef
OptObject(jni::String::Param name, NativeJSObject::Param fallback)
{
return GetProperty<ObjectProperty>(name, &fallback);
}
jni::ObjectArray::LocalRef
GetObjectArray(jni::String::Param name)
{
return GetProperty<ObjectArrayProperty>(name);
}
jni::ObjectArray::LocalRef
OptObjectArray(jni::String::Param name, jni::ObjectArray::Param fallback)
{
return GetProperty<ObjectArrayProperty>(name, &fallback);
}
jni::String::LocalRef
GetString(jni::String::Param name)
{
return GetProperty<StringProperty>(name);
}
jni::String::LocalRef
OptString(jni::String::Param name, jni::String::Param fallback)
{
return GetProperty<StringProperty>(name, &fallback);
}
jni::ObjectArray::LocalRef
GetStringArray(jni::String::Param name)
{
return GetProperty<StringArrayProperty>(name);
}
jni::ObjectArray::LocalRef
OptStringArray(jni::String::Param name, jni::ObjectArray::Param fallback)
{
return GetProperty<StringArrayProperty>(name, &fallback);
}
bool Has(jni::String::Param name)
{
bool no = false;
// Fallback to false indicating no such property.
return GetProperty<HasProperty>(name, &no);
}
jni::Object::LocalRef ToBundle()
{
if (!CheckThread() || !CheckObject()) {
return nullptr;
}
return BundleFromValue(mJSObject);
}
private:
static bool AppendJSON(const char16_t* buf, uint32_t len, void* data)
{
static_cast<nsAutoString*>(data)->Append(buf, len);
return true;
}
public:
jni::String::LocalRef ToString()
{
if (!CheckThread() || !CheckObject()) {
return nullptr;
}
JS::RootedValue value(mJSContext, JS::ObjectValue(*mJSObject));
nsAutoString json;
if (!CheckJSCall(JS_Stringify(mJSContext, &value, nullptr,
JS::NullHandleValue, AppendJSON, &json))) {
return nullptr;
}
return jni::StringParam(json, mEnv);
}
};
// Define the "static constexpr" members of our property types (e.g.
// PrimitiveProperty<>::InValue). This is tricky because there are a lot of
// template parameters, so we use macros to make it simpler.
#define DEFINE_PRIMITIVE_PROPERTY_MEMBER(Name) \
template<typename U, typename UA, typename V, typename VA, \
bool (JS::Value::*I)() const, \
U (JS::Value::*T)() const, \
VA (JNIEnv::*N)(jsize), \
void (JNIEnv::*S)(VA, jsize, jsize, const V*)> \
constexpr typename NativeJSContainerImpl \
::PrimitiveProperty<U, UA, V, VA, I, T, N, S>::Name##_t \
NativeJSContainerImpl::PrimitiveProperty<U, UA, V, VA, I, T, N, S>::Name
DEFINE_PRIMITIVE_PROPERTY_MEMBER(NewJNIArray);
DEFINE_PRIMITIVE_PROPERTY_MEMBER(SetJNIArrayRegion);
DEFINE_PRIMITIVE_PROPERTY_MEMBER(InValue);
DEFINE_PRIMITIVE_PROPERTY_MEMBER(FromValue);
DEFINE_PRIMITIVE_PROPERTY_MEMBER(NewArray);
#undef DEFINE_PRIMITIVE_PROPERTY_MEMBER
#define DEFINE_OBJECT_PROPERTY_MEMBER(Name) \
template<class C, \
bool (NativeJSContainerImpl::*I)(JS::HandleValue) const, \
typename C::LocalRef (NativeJSContainerImpl::*F)(JS::HandleValue)> \
constexpr typename NativeJSContainerImpl \
::BaseObjectProperty<C, I, F>::Name##_t \
NativeJSContainerImpl::BaseObjectProperty<C, I, F>::Name
DEFINE_OBJECT_PROPERTY_MEMBER(InValue);
DEFINE_OBJECT_PROPERTY_MEMBER(FromValue);
DEFINE_OBJECT_PROPERTY_MEMBER(NewArray);
#undef DEFINE_OBJECT_PROPERTY_MEMBER
template<class P> constexpr typename NativeJSContainerImpl::ArrayProperty<P>
::InValue_t NativeJSContainerImpl::ArrayProperty<P>::InValue;
template<class P> constexpr typename NativeJSContainerImpl::ArrayProperty<P>
::FromValue_t NativeJSContainerImpl::ArrayProperty<P>::FromValue;
constexpr NativeJSContainerImpl::HasProperty::HasValue_t
NativeJSContainerImpl::HasProperty::InValue;
constexpr NativeJSContainerImpl::HasProperty::HasValue_t
NativeJSContainerImpl::HasProperty::FromValue;
NativeJSContainer::LocalRef
CreateNativeJSContainer(JSContext* cx, JS::HandleObject object)
{
return NativeJSContainerImpl::CreateInstance(cx, object);
}
} // namespace widget
} // namespace mozilla

View file

@ -1,22 +0,0 @@
/* -*- Mode: c++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef NativeJSObject_h__
#define NativeJSObject_h__
#include "GeneratedJNIWrappers.h"
#include "jsapi.h"
namespace mozilla {
namespace widget {
java::NativeJSContainer::LocalRef
CreateNativeJSContainer(JSContext* cx, JS::HandleObject object);
} // namespace widget
} // namespace mozilla
#endif // NativeJSObject_h__

View file

@ -1,324 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef PrefsHelper_h
#define PrefsHelper_h
#include "GeneratedJNINatives.h"
#include "MainThreadUtils.h"
#include "nsAppShell.h"
#include "nsCOMPtr.h"
#include "nsVariant.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
namespace mozilla {
class PrefsHelper
: public java::PrefsHelper::Natives<PrefsHelper>
{
PrefsHelper() = delete;
static bool GetVariantPref(nsIObserverService* aObsServ,
nsIWritableVariant* aVariant,
jni::Object::Param aPrefHandler,
const jni::String::LocalRef& aPrefName)
{
if (NS_FAILED(aObsServ->NotifyObservers(aVariant, "android-get-pref",
aPrefName->ToString().get()))) {
return false;
}
uint16_t varType = nsIDataType::VTYPE_EMPTY;
if (NS_FAILED(aVariant->GetDataType(&varType))) {
return false;
}
int32_t type = java::PrefsHelper::PREF_INVALID;
bool boolVal = false;
int32_t intVal = 0;
nsAutoString strVal;
switch (varType) {
case nsIDataType::VTYPE_BOOL:
type = java::PrefsHelper::PREF_BOOL;
if (NS_FAILED(aVariant->GetAsBool(&boolVal))) {
return false;
}
break;
case nsIDataType::VTYPE_INT32:
type = java::PrefsHelper::PREF_INT;
if (NS_FAILED(aVariant->GetAsInt32(&intVal))) {
return false;
}
break;
case nsIDataType::VTYPE_ASTRING:
type = java::PrefsHelper::PREF_STRING;
if (NS_FAILED(aVariant->GetAsAString(strVal))) {
return false;
}
break;
default:
return false;
}
jni::StringParam jstrVal(type == java::PrefsHelper::PREF_STRING ?
jni::StringParam(strVal, aPrefName.Env()) :
jni::StringParam(nullptr));
if (aPrefHandler) {
java::PrefsHelper::CallPrefHandler(
aPrefHandler, type, aPrefName,
boolVal, intVal, jstrVal);
} else {
java::PrefsHelper::OnPrefChange(
aPrefName, type, boolVal, intVal, jstrVal);
}
return true;
}
static bool SetVariantPref(nsIObserverService* aObsServ,
nsIWritableVariant* aVariant,
jni::String::Param aPrefName,
bool aFlush,
int32_t aType,
bool aBoolVal,
int32_t aIntVal,
jni::String::Param aStrVal)
{
nsresult rv = NS_ERROR_FAILURE;
switch (aType) {
case java::PrefsHelper::PREF_BOOL:
rv = aVariant->SetAsBool(aBoolVal);
break;
case java::PrefsHelper::PREF_INT:
rv = aVariant->SetAsInt32(aIntVal);
break;
case java::PrefsHelper::PREF_STRING:
rv = aVariant->SetAsAString(aStrVal->ToString());
break;
}
if (NS_SUCCEEDED(rv)) {
rv = aObsServ->NotifyObservers(aVariant, "android-set-pref",
aPrefName->ToString().get());
}
uint16_t varType = nsIDataType::VTYPE_EMPTY;
if (NS_SUCCEEDED(rv)) {
rv = aVariant->GetDataType(&varType);
}
// We use set-to-empty to signal the pref was handled.
const bool handled = varType == nsIDataType::VTYPE_EMPTY;
if (NS_SUCCEEDED(rv) && handled && aFlush) {
rv = Preferences::GetService()->SavePrefFile(nullptr);
}
if (NS_SUCCEEDED(rv)) {
return handled;
}
NS_WARNING(nsPrintfCString("Failed to set pref %s",
aPrefName->ToCString().get()).get());
// Pretend we handled the pref.
return true;
}
public:
static void GetPrefs(const jni::Class::LocalRef& aCls,
jni::ObjectArray::Param aPrefNames,
jni::Object::Param aPrefHandler)
{
nsTArray<jni::Object::LocalRef> nameRefArray(aPrefNames->GetElements());
nsCOMPtr<nsIObserverService> obsServ;
nsCOMPtr<nsIWritableVariant> value;
nsAdoptingString strVal;
for (jni::Object::LocalRef& nameRef : nameRefArray) {
jni::String::LocalRef nameStr(mozilla::Move(nameRef));
const nsCString& name = nameStr->ToCString();
int32_t type = java::PrefsHelper::PREF_INVALID;
bool boolVal = false;
int32_t intVal = 0;
switch (Preferences::GetType(name.get())) {
case nsIPrefBranch::PREF_BOOL:
type = java::PrefsHelper::PREF_BOOL;
boolVal = Preferences::GetBool(name.get());
break;
case nsIPrefBranch::PREF_INT:
type = java::PrefsHelper::PREF_INT;
intVal = Preferences::GetInt(name.get());
break;
case nsIPrefBranch::PREF_STRING:
type = java::PrefsHelper::PREF_STRING;
strVal = Preferences::GetLocalizedString(name.get());
if (!strVal) {
strVal = Preferences::GetString(name.get());
}
break;
default:
// Pref not found; try to find it.
if (!obsServ) {
obsServ = services::GetObserverService();
if (!obsServ) {
continue;
}
}
if (value) {
value->SetAsEmpty();
} else {
value = new nsVariant();
}
if (!GetVariantPref(obsServ, value,
aPrefHandler, nameStr)) {
NS_WARNING(nsPrintfCString("Failed to get pref %s",
name.get()).get());
}
continue;
}
java::PrefsHelper::CallPrefHandler(
aPrefHandler, type, nameStr, boolVal, intVal,
jni::StringParam(type == java::PrefsHelper::PREF_STRING ?
jni::StringParam(strVal, aCls.Env()) :
jni::StringParam(nullptr)));
}
java::PrefsHelper::CallPrefHandler(
aPrefHandler, java::PrefsHelper::PREF_FINISH,
nullptr, false, 0, nullptr);
}
static void SetPref(jni::String::Param aPrefName,
bool aFlush,
int32_t aType,
bool aBoolVal,
int32_t aIntVal,
jni::String::Param aStrVal)
{
const nsCString& name = aPrefName->ToCString();
if (Preferences::GetType(name.get()) == nsIPrefBranch::PREF_INVALID) {
// No pref; try asking first.
nsCOMPtr<nsIObserverService> obsServ =
services::GetObserverService();
nsCOMPtr<nsIWritableVariant> value = new nsVariant();
if (obsServ && SetVariantPref(obsServ, value, aPrefName, aFlush,
aType, aBoolVal, aIntVal, aStrVal)) {
// The "pref" has changed; send a notification.
GetVariantPref(obsServ, value, nullptr,
jni::String::LocalRef(aPrefName));
return;
}
}
switch (aType) {
case java::PrefsHelper::PREF_BOOL:
Preferences::SetBool(name.get(), aBoolVal);
break;
case java::PrefsHelper::PREF_INT:
Preferences::SetInt(name.get(), aIntVal);
break;
case java::PrefsHelper::PREF_STRING:
Preferences::SetString(name.get(), aStrVal->ToString());
break;
default:
MOZ_ASSERT(false, "Invalid pref type");
}
if (aFlush) {
Preferences::GetService()->SavePrefFile(nullptr);
}
}
static void AddObserver(const jni::Class::LocalRef& aCls,
jni::ObjectArray::Param aPrefNames,
jni::Object::Param aPrefHandler,
jni::ObjectArray::Param aPrefsToObserve)
{
// Call observer immediately with existing pref values.
GetPrefs(aCls, aPrefNames, aPrefHandler);
if (!aPrefsToObserve) {
return;
}
nsTArray<jni::Object::LocalRef> nameRefArray(
aPrefsToObserve->GetElements());
nsAppShell* const appShell = nsAppShell::Get();
MOZ_ASSERT(appShell);
for (jni::Object::LocalRef& nameRef : nameRefArray) {
jni::String::LocalRef nameStr(mozilla::Move(nameRef));
MOZ_ALWAYS_SUCCEEDS(Preferences::AddStrongObserver(
appShell, nameStr->ToCString().get()));
}
}
static void RemoveObserver(const jni::Class::LocalRef& aCls,
jni::ObjectArray::Param aPrefsToUnobserve)
{
nsTArray<jni::Object::LocalRef> nameRefArray(
aPrefsToUnobserve->GetElements());
nsAppShell* const appShell = nsAppShell::Get();
MOZ_ASSERT(appShell);
for (jni::Object::LocalRef& nameRef : nameRefArray) {
jni::String::LocalRef nameStr(mozilla::Move(nameRef));
MOZ_ALWAYS_SUCCEEDS(Preferences::RemoveObserver(
appShell, nameStr->ToCString().get()));
}
}
static void OnPrefChange(const char16_t* aData)
{
const nsCString& name = NS_LossyConvertUTF16toASCII(aData);
int32_t type = -1;
bool boolVal = false;
int32_t intVal = false;
nsAdoptingString strVal;
switch (Preferences::GetType(name.get())) {
case nsIPrefBranch::PREF_BOOL:
type = java::PrefsHelper::PREF_BOOL;
boolVal = Preferences::GetBool(name.get());
break;
case nsIPrefBranch::PREF_INT:
type = java::PrefsHelper::PREF_INT;
intVal = Preferences::GetInt(name.get());
break;
case nsIPrefBranch::PREF_STRING:
type = java::PrefsHelper::PREF_STRING;
strVal = Preferences::GetLocalizedString(name.get());
if (!strVal) {
strVal = Preferences::GetString(name.get());
}
break;
default:
NS_WARNING(nsPrintfCString("Invalid pref %s",
name.get()).get());
return;
}
java::PrefsHelper::OnPrefChange(
name, type, boolVal, intVal,
jni::StringParam(type == java::PrefsHelper::PREF_STRING ?
jni::StringParam(strVal) : jni::StringParam(nullptr)));
}
};
} // namespace
#endif // PrefsHelper_h

View file

@ -1,2 +0,0 @@
android.graphics.Rect
android.graphics.RectF

View file

@ -1 +0,0 @@
android.os.Bundle

View file

@ -1 +0,0 @@
android.view.KeyEvent

View file

@ -1,27 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Bug 1099345 - The SDK's lint code (used by the code generator) does not enjoy
# concurrent access to a cache that it generates.
.NOTPARALLEL:
annotation_processor_jar_files := \
$(DEPTH)/build/annotationProcessors/annotationProcessors.jar \
$(ANDROID_TOOLS)/lib/lint.jar \
$(ANDROID_TOOLS)/lib/lint-checks.jar \
$(NULL)
sdk_processor := \
$(JAVA) \
-Dcom.android.tools.lint.bindir='$(ANDROID_TOOLS)' \
-classpath $(subst $(NULL) ,:,$(strip $(annotation_processor_jar_files))) \
org.mozilla.gecko.annotationProcessors.SDKProcessor
# For the benefit of readers: the following pattern rule says that,
# for example, MediaCodec.cpp and MediaCodec.h can be produced from
# MediaCodec-classes.txt. This formulation invokes the SDK processor
# at most once.
%.cpp %.h: $(ANDROID_SDK)/android.jar %-classes.txt $(annotation_processor_jar_files)
$(sdk_processor) $(ANDROID_SDK)/android.jar $(srcdir)/$*-classes.txt $(CURDIR) $* 16

View file

@ -1,5 +0,0 @@
android.media.MediaCodec
android.media.MediaCodec$BufferInfo
android.media.MediaCodec$CryptoInfo
android.media.MediaDrm$KeyStatus
android.media.MediaFormat

View file

@ -1 +0,0 @@
android.view.MotionEvent

Some files were not shown because too many files have changed in this diff Show more