Bug 913985 - Part 5: refactor the Bridge to use the generated code. r=kats
This commit is contained in:
@@ -1791,7 +1791,7 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
|
|||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available");
|
||||||
if (AndroidBridge::Bridge() != nullptr)
|
if (AndroidBridge::Bridge() != nullptr)
|
||||||
*showPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
|
*showPassword = GeckoAppShell::GetShowPasswordSetting();
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2262,11 +2262,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case kJavaContext_ANPGetValue: {
|
case kJavaContext_ANPGetValue: {
|
||||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
jobject ret = GeckoAppShell::GetContext();
|
||||||
if (!bridge)
|
|
||||||
return NPERR_GENERIC_ERROR;
|
|
||||||
|
|
||||||
jobject ret = bridge->GetContext();
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NPERR_GENERIC_ERROR;
|
return NPERR_GENERIC_ERROR;
|
||||||
|
|
||||||
|
|||||||
@@ -868,7 +868,7 @@ void nsNPAPIPluginInstance::NotifyFullScreen(bool aFullScreen)
|
|||||||
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
|
SendLifecycleEvent(this, mFullScreen ? kEnterFullScreen_ANPLifecycleAction : kExitFullScreen_ANPLifecycleAction);
|
||||||
|
|
||||||
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
|
if (mFullScreen && mFullScreenOrientation != dom::eScreenOrientation_None) {
|
||||||
AndroidBridge::Bridge()->LockScreenOrientation(mFullScreenOrientation);
|
GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -925,11 +925,11 @@ void nsNPAPIPluginInstance::SetFullScreenOrientation(uint32_t orientation)
|
|||||||
// We're already fullscreen so immediately apply the orientation change
|
// We're already fullscreen so immediately apply the orientation change
|
||||||
|
|
||||||
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
|
if (mFullScreenOrientation != dom::eScreenOrientation_None) {
|
||||||
AndroidBridge::Bridge()->LockScreenOrientation(mFullScreenOrientation);
|
GeckoAppShell::LockScreenOrientation(mFullScreenOrientation);
|
||||||
} else if (oldOrientation != dom::eScreenOrientation_None) {
|
} else if (oldOrientation != dom::eScreenOrientation_None) {
|
||||||
// We applied an orientation when we entered fullscreen, but
|
// We applied an orientation when we entered fullscreen, but
|
||||||
// we don't want it anymore
|
// we don't want it anymore
|
||||||
AndroidBridge::Bridge()->UnlockScreenOrientation();
|
GeckoAppShell::UnlockScreenOrientation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1672,9 +1672,7 @@ void nsPluginInstanceOwner::RemovePluginView()
|
|||||||
if (!mInstance || !mJavaView)
|
if (!mInstance || !mJavaView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (AndroidBridge::Bridge())
|
GeckoAppShell::RemovePluginView((jobject)mJavaView, mFullScreen);
|
||||||
AndroidBridge::Bridge()->RemovePluginView((jobject)mJavaView, mFullScreen);
|
|
||||||
|
|
||||||
AndroidBridge::GetJNIEnv()->DeleteGlobalRef((jobject)mJavaView);
|
AndroidBridge::GetJNIEnv()->DeleteGlobalRef((jobject)mJavaView);
|
||||||
mJavaView = nullptr;
|
mJavaView = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ AndroidLocationProvider::Startup()
|
|||||||
{
|
{
|
||||||
if (!AndroidBridge::Bridge())
|
if (!AndroidBridge::Bridge())
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
AndroidBridge::Bridge()->EnableLocation(true);
|
GeckoAppShell::EnableLocation(true);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ AndroidLocationProvider::Shutdown()
|
|||||||
{
|
{
|
||||||
if (!AndroidBridge::Bridge())
|
if (!AndroidBridge::Bridge())
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
AndroidBridge::Bridge()->EnableLocation(false);
|
GeckoAppShell::EnableLocation(false);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +55,6 @@ AndroidLocationProvider::SetHighAccuracy(bool enable)
|
|||||||
{
|
{
|
||||||
if (!AndroidBridge::Bridge())
|
if (!AndroidBridge::Bridge())
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
AndroidBridge::Bridge()->EnableLocationHighAccuracy(enable);
|
GeckoAppShell::EnableLocationHighAccuracy(enable);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ nsHapticFeedback::PerformSimpleAction(int32_t aType)
|
|||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||||
if (bridge) {
|
if (bridge) {
|
||||||
bridge->PerformHapticFeedback(aType == LongPress);
|
GeckoAppShell::PerformHapticFeedback(aType == LongPress);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|||||||
@@ -2515,7 +2515,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual already_AddRefed<TextureImage>
|
virtual already_AddRefed<TextureImage>
|
||||||
CreateDirectTextureImage(android::GraphicBuffer* aBuffer, GLenum aWrapMode)
|
CreateDirectTextureImage(::android::GraphicBuffer* aBuffer, GLenum aWrapMode)
|
||||||
{ return nullptr; }
|
{ return nullptr; }
|
||||||
|
|
||||||
// Before reads from offscreen texture
|
// Before reads from offscreen texture
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ nsSurfaceTexture::~nsSurfaceTexture()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (mSurfaceTexture && env) {
|
if (mSurfaceTexture && env) {
|
||||||
AndroidBridge::Bridge()->UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
||||||
|
|
||||||
env->DeleteGlobalRef(mSurfaceTexture);
|
env->DeleteGlobalRef(mSurfaceTexture);
|
||||||
mSurfaceTexture = nullptr;
|
mSurfaceTexture = nullptr;
|
||||||
@@ -239,9 +239,9 @@ void
|
|||||||
nsSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
|
nsSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
|
||||||
{
|
{
|
||||||
if (aRunnable)
|
if (aRunnable)
|
||||||
AndroidBridge::Bridge()->RegisterSurfaceTextureFrameListener(mSurfaceTexture, mID);
|
GeckoAppShell::RegisterSurfaceTextureFrameListener(mSurfaceTexture, mID);
|
||||||
else
|
else
|
||||||
AndroidBridge::Bridge()->UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
|
||||||
|
|
||||||
mFrameAvailableCallback = aRunnable;
|
mFrameAvailableCallback = aRunnable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
using namespace mozilla::hal;
|
using namespace mozilla::hal;
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace hal_impl {
|
namespace hal_impl {
|
||||||
@@ -54,97 +55,55 @@ CancelVibrate(const WindowIdentifier &)
|
|||||||
{
|
{
|
||||||
// Ignore WindowIdentifier parameter.
|
// Ignore WindowIdentifier parameter.
|
||||||
|
|
||||||
AndroidBridge* b = AndroidBridge::Bridge();
|
GeckoAppShell::CancelVibrate();
|
||||||
if (b)
|
|
||||||
b->CancelVibrate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EnableBatteryNotifications()
|
EnableBatteryNotifications()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::EnableBatteryNotifications();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->EnableBatteryNotifications();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DisableBatteryNotifications()
|
DisableBatteryNotifications()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::DisableBatteryNotifications();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->DisableBatteryNotifications();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
|
GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo)
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
AndroidBridge::Bridge()->GetCurrentBatteryInformation(aBatteryInfo);
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->GetCurrentBatteryInformation(aBatteryInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EnableNetworkNotifications()
|
EnableNetworkNotifications()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::EnableNetworkNotifications();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->EnableNetworkNotifications();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DisableNetworkNotifications()
|
DisableNetworkNotifications()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::DisableNetworkNotifications();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->DisableNetworkNotifications();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
AndroidBridge::Bridge()->GetCurrentNetworkInformation(aNetworkInfo);
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->GetCurrentNetworkInformation(aNetworkInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EnableScreenConfigurationNotifications()
|
EnableScreenConfigurationNotifications()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::EnableScreenOrientationNotifications();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->EnableScreenOrientationNotifications();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DisableScreenConfigurationNotifications()
|
DisableScreenConfigurationNotifications()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::DisableScreenOrientationNotifications();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->DisableScreenOrientationNotifications();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -181,8 +140,7 @@ GetCurrentScreenConfiguration(ScreenConfiguration* aScreenConfiguration)
|
|||||||
bool
|
bool
|
||||||
LockScreenOrientation(const ScreenOrientation& aOrientation)
|
LockScreenOrientation(const ScreenOrientation& aOrientation)
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
if (!AndroidBridge::Bridge()) {
|
||||||
if (!bridge) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +153,7 @@ LockScreenOrientation(const ScreenOrientation& aOrientation)
|
|||||||
case eScreenOrientation_LandscapeSecondary:
|
case eScreenOrientation_LandscapeSecondary:
|
||||||
case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
|
case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
|
||||||
case eScreenOrientation_Default:
|
case eScreenOrientation_Default:
|
||||||
bridge->LockScreenOrientation(aOrientation);
|
GeckoAppShell::LockScreenOrientation(aOrientation);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -205,12 +163,7 @@ LockScreenOrientation(const ScreenOrientation& aOrientation)
|
|||||||
void
|
void
|
||||||
UnlockScreenOrientation()
|
UnlockScreenOrientation()
|
||||||
{
|
{
|
||||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
GeckoAppShell::UnlockScreenOrientation();
|
||||||
if (!bridge) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bridge->UnlockScreenOrientation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // hal_impl
|
} // hal_impl
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ namespace hal_impl {
|
|||||||
|
|
||||||
void
|
void
|
||||||
EnableSensorNotifications(SensorType aSensor) {
|
EnableSensorNotifications(SensorType aSensor) {
|
||||||
AndroidBridge::Bridge()->EnableSensor(aSensor);
|
GeckoAppShell::EnableSensor(aSensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DisableSensorNotifications(SensorType aSensor) {
|
DisableSensorNotifications(SensorType aSensor) {
|
||||||
AndroidBridge::Bridge()->DisableSensor(aSensor);
|
GeckoAppShell::DisableSensor(aSensor);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // hal_impl
|
} // hal_impl
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ MessagePump::Run(MessagePump::Delegate* aDelegate)
|
|||||||
// This processes messages in the Android Looper. Note that we only
|
// This processes messages in the Android Looper. Note that we only
|
||||||
// get here if the normal Gecko event loop has been awoken above.
|
// get here if the normal Gecko event loop has been awoken above.
|
||||||
// Bug 750713
|
// Bug 750713
|
||||||
did_work |= AndroidBridge::Bridge()->PumpMessageLoop();
|
did_work |= GeckoAppShell::PumpMessageLoop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
did_work |= aDelegate->DoDelayedWork(&delayed_work_time_);
|
did_work |= aDelegate->DoDelayedWork(&delayed_work_time_);
|
||||||
|
|||||||
@@ -50,10 +50,7 @@ nsAndroidHistory::RegisterVisitedCallback(nsIURI *aURI, Link *aContent)
|
|||||||
}
|
}
|
||||||
list->AppendElement(aContent);
|
list->AppendElement(aContent);
|
||||||
|
|
||||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
GeckoAppShell::CheckURIVisited(uriString);
|
||||||
if (bridge) {
|
|
||||||
bridge->CheckURIVisited(uriString);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -96,13 +93,12 @@ nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlag
|
|||||||
if (aFlags & VisitFlags::UNRECOVERABLE_ERROR)
|
if (aFlags & VisitFlags::UNRECOVERABLE_ERROR)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
if (AndroidBridge::Bridge()) {
|
||||||
if (bridge) {
|
|
||||||
nsAutoCString uri;
|
nsAutoCString uri;
|
||||||
nsresult rv = aURI->GetSpec(uri);
|
nsresult rv = aURI->GetSpec(uri);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
NS_ConvertUTF8toUTF16 uriString(uri);
|
NS_ConvertUTF8toUTF16 uriString(uri);
|
||||||
bridge->MarkURIVisited(uriString);
|
GeckoAppShell::MarkURIVisited(uriString);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@@ -110,13 +106,12 @@ nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlag
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAndroidHistory::SetURITitle(nsIURI *aURI, const nsAString& aTitle)
|
nsAndroidHistory::SetURITitle(nsIURI *aURI, const nsAString& aTitle)
|
||||||
{
|
{
|
||||||
AndroidBridge *bridge = AndroidBridge::Bridge();
|
if (AndroidBridge::Bridge()) {
|
||||||
if (bridge) {
|
|
||||||
nsAutoCString uri;
|
nsAutoCString uri;
|
||||||
nsresult rv = aURI->GetSpec(uri);
|
nsresult rv = aURI->GetSpec(uri);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
NS_ConvertUTF8toUTF16 uriString(uri);
|
NS_ConvertUTF8toUTF16 uriString(uri);
|
||||||
bridge->SetURITitle(uriString, aTitle);
|
GeckoAppShell::SetURITitle(uriString, aTitle);
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsShellService, nsIShellService)
|
NS_IMPL_ISUPPORTS1(nsShellService, nsIShellService)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -22,6 +24,6 @@ nsShellService::CreateShortcut(const nsAString& aTitle, const nsAString& aURI, c
|
|||||||
if (!aTitle.Length() || !aURI.Length() || !aIconData.Length())
|
if (!aTitle.Length() || !aURI.Length() || !aIconData.Length())
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
mozilla::AndroidBridge::Bridge()->CreateShortcut(aTitle, aURI, aIconData, aIntent);
|
GeckoAppShell::CreateShortcut(aTitle, aURI, aIconData, aIntent);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ Tickler::Init()
|
|||||||
MOZ_ASSERT(!mThread);
|
MOZ_ASSERT(!mThread);
|
||||||
MOZ_ASSERT(!mFD);
|
MOZ_ASSERT(!mFD);
|
||||||
|
|
||||||
AndroidBridge::Bridge()->EnableNetworkNotifications();
|
GeckoAppShell::EnableNetworkNotifications();
|
||||||
|
|
||||||
mFD = PR_OpenUDPSocket(PR_AF_INET);
|
mFD = PR_OpenUDPSocket(PR_AF_INET);
|
||||||
if (!mFD)
|
if (!mFD)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ bool CameraStreamImpl::Init(const nsCString& contentType, const uint32_t& camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CameraStreamImpl::Close() {
|
void CameraStreamImpl::Close() {
|
||||||
AndroidBridge::Bridge()->CloseCamera();
|
GeckoAppShell::CloseCamera();
|
||||||
mCallback = nullptr;
|
mCallback = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsAndroidNetworkLinkService,
|
NS_IMPL_ISUPPORTS1(nsAndroidNetworkLinkService,
|
||||||
nsINetworkLinkService)
|
nsINetworkLinkService)
|
||||||
|
|
||||||
@@ -31,7 +33,7 @@ nsAndroidNetworkLinkService::GetIsLinkUp(bool *aIsUp)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
*aIsUp = mozilla::AndroidBridge::Bridge()->IsNetworkLinkUp();
|
*aIsUp = GeckoAppShell::IsNetworkLinkUp();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ nsAndroidNetworkLinkService::GetLinkStatusKnown(bool *aIsKnown)
|
|||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
|
NS_ENSURE_TRUE(mozilla::AndroidBridge::Bridge(), NS_ERROR_NOT_IMPLEMENTED);
|
||||||
|
|
||||||
*aIsKnown = mozilla::AndroidBridge::Bridge()->IsNetworkLinkKnown();
|
*aIsKnown = GeckoAppShell::IsNetworkLinkKnown();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "nsXPCOM.h"
|
#include "nsXPCOM.h"
|
||||||
@@ -127,7 +128,7 @@ NS_IMETHODIMP nsAlertsService::CloseAlert(const nsAString& aAlertName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
mozilla::AndroidBridge::Bridge()->CloseNotification(aAlertName);
|
GeckoAppShell::CloseNotification(aAlertName);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ NS_IMETHODIMP nsAlertsService::OnProgress(const nsAString & aAlertName,
|
|||||||
const nsAString & aAlertText)
|
const nsAString & aAlertText)
|
||||||
{
|
{
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
mozilla::AndroidBridge::Bridge()->AlertsProgressListener_OnProgress(aAlertName, aProgress, aProgressMax, aAlertText);
|
GeckoAppShell::AlertsProgressListener_OnProgress(aAlertName, aProgress, aProgressMax, aAlertText);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
#else
|
#else
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
@@ -158,7 +159,7 @@ NS_IMETHODIMP nsAlertsService::OnProgress(const nsAString & aAlertName,
|
|||||||
NS_IMETHODIMP nsAlertsService::OnCancel(const nsAString & aAlertName)
|
NS_IMETHODIMP nsAlertsService::OnCancel(const nsAString & aAlertName)
|
||||||
{
|
{
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
mozilla::AndroidBridge::Bridge()->CloseNotification(aAlertName);
|
GeckoAppShell::CloseNotification(aAlertName);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
#else
|
#else
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GTK
|
#ifdef MOZ_WIDGET_GTK
|
||||||
@@ -2797,7 +2798,7 @@ nsDownload::SetState(DownloadState aState)
|
|||||||
if (mimeInfo)
|
if (mimeInfo)
|
||||||
mimeInfo->GetMIMEType(contentType);
|
mimeInfo->GetMIMEType(contentType);
|
||||||
|
|
||||||
mozilla::AndroidBridge::Bridge()->ScanMedia(path, NS_ConvertUTF8toUTF16(contentType));
|
GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(contentType));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget,
|
|||||||
#endif
|
#endif
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
if (!aContentType.IsEmpty()) {
|
if (!aContentType.IsEmpty()) {
|
||||||
mozilla::AndroidBridge::Bridge()->ScanMedia(path, NS_ConvertUTF8toUTF16(aContentType));
|
mozilla::widget::android::GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(aContentType));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ GeckoStart(void *data, const nsXREAppData *appData)
|
|||||||
if (result)
|
if (result)
|
||||||
LOG("XRE_main returned %d", result);
|
LOG("XRE_main returned %d", result);
|
||||||
|
|
||||||
mozilla::AndroidBridge::Bridge()->NotifyXreExit();
|
mozilla::widget::android::GeckoAppShell::NotifyXreExit();
|
||||||
|
|
||||||
free(targs[0]);
|
free(targs[0]);
|
||||||
nsMemory::Free(data);
|
nsMemory::Free(data);
|
||||||
|
|||||||
@@ -1649,7 +1649,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
|
|||||||
SaveToEnv("MOZ_LAUNCHED_CHILD=1");
|
SaveToEnv("MOZ_LAUNCHED_CHILD=1");
|
||||||
|
|
||||||
#if defined(MOZ_WIDGET_ANDROID)
|
#if defined(MOZ_WIDGET_ANDROID)
|
||||||
mozilla::AndroidBridge::Bridge()->ScheduleRestart();
|
mozilla::widget::android::GeckoAppShell::ScheduleRestart();
|
||||||
#else
|
#else
|
||||||
#if defined(XP_MACOSX)
|
#if defined(XP_MACOSX)
|
||||||
CommandLineServiceMac::SetupMacCommandLine(gRestartArgc, gRestartArgv, true);
|
CommandLineServiceMac::SetupMacCommandLine(gRestartArgc, gRestartArgv, true);
|
||||||
@@ -1761,7 +1761,7 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
|
|||||||
if (aUnlocker) {
|
if (aUnlocker) {
|
||||||
int32_t button;
|
int32_t button;
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
mozilla::AndroidBridge::Bridge()->KillAnyZombies();
|
mozilla::widget::android::GeckoAppShell::KillAnyZombies();
|
||||||
button = 1;
|
button = 1;
|
||||||
#else
|
#else
|
||||||
const uint32_t flags =
|
const uint32_t flags =
|
||||||
@@ -1788,7 +1788,7 @@ ProfileLockedDialog(nsIFile* aProfileDir, nsIFile* aProfileLocalDir,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
if (mozilla::AndroidBridge::Bridge()->UnlockProfile()) {
|
if (mozilla::widget::android::GeckoAppShell::UnlockProfile()) {
|
||||||
return NS_LockProfilePath(aProfileDir, aProfileLocalDir,
|
return NS_LockProfilePath(aProfileDir, aProfileLocalDir,
|
||||||
nullptr, aResult);
|
nullptr, aResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ typename Builder::Object BuildJavaThreadJSObject(Builder& b)
|
|||||||
b.DefineProperty(sample, "frames", frames);
|
b.DefineProperty(sample, "frames", frames);
|
||||||
b.ArrayPush(samples, sample);
|
b.ArrayPush(samples, sample);
|
||||||
|
|
||||||
double sampleTime = AndroidBridge::Bridge()->GetSampleTimeJavaProfiling(0, sampleId);
|
double sampleTime = GeckoJavaSampler::GetSampleTimeJavaProfiling(0, sampleId);
|
||||||
b.DefineProperty(sample, "time", sampleTime);
|
b.DefineProperty(sample, "time", sampleTime);
|
||||||
}
|
}
|
||||||
typename Builder::RootedObject frame(b.context(), b.CreateObject());
|
typename Builder::RootedObject frame(b.context(), b.CreateObject());
|
||||||
@@ -282,12 +282,12 @@ void TableTicker::BuildJSObject(Builder& b, typename Builder::ObjectHandle profi
|
|||||||
|
|
||||||
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
|
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
|
||||||
if (ProfileJava()) {
|
if (ProfileJava()) {
|
||||||
AndroidBridge::Bridge()->PauseJavaProfiling();
|
GeckoJavaSampler::PauseJavaProfiling();
|
||||||
|
|
||||||
typename Builder::RootedObject javaThread(b.context(), BuildJavaThreadJSObject(b));
|
typename Builder::RootedObject javaThread(b.context(), BuildJavaThreadJSObject(b));
|
||||||
b.ArrayPush(threads, javaThread);
|
b.ArrayPush(threads, javaThread);
|
||||||
|
|
||||||
AndroidBridge::Bridge()->UnpauseJavaProfiling();
|
GeckoJavaSampler::UnpauseJavaProfiling();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
|
#if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mozilla::ThreadLocal<PseudoStack *> tlsPseudoStack;
|
mozilla::ThreadLocal<PseudoStack *> tlsPseudoStack;
|
||||||
@@ -675,7 +676,7 @@ void mozilla_sampler_start(int aProfileEntries, double aInterval,
|
|||||||
if (javaInterval < 10) {
|
if (javaInterval < 10) {
|
||||||
aInterval = 10;
|
aInterval = 10;
|
||||||
}
|
}
|
||||||
mozilla::AndroidBridge::Bridge()->StartJavaProfiling(javaInterval, 1000);
|
GeckoJavaSampler::StartJavaProfiling(javaInterval, 1000);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "nsAndroidHandlerApp.h"
|
#include "nsAndroidHandlerApp.h"
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS2(nsAndroidHandlerApp, nsIHandlerApp, nsISharingHandlerApp)
|
NS_IMPL_ISUPPORTS2(nsAndroidHandlerApp, nsIHandlerApp, nsISharingHandlerApp)
|
||||||
|
|
||||||
@@ -70,8 +72,7 @@ nsAndroidHandlerApp::LaunchWithURI(nsIURI *aURI, nsIInterfaceRequestor *aWindowC
|
|||||||
|
|
||||||
nsCString uriSpec;
|
nsCString uriSpec;
|
||||||
aURI->GetSpec(uriSpec);
|
aURI->GetSpec(uriSpec);
|
||||||
return mozilla::AndroidBridge::Bridge()->
|
return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ?
|
||||||
OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), NS_ConvertUTF8toUTF16(mMimeType), mPackageName, mClassName, mAction) ?
|
|
||||||
NS_OK : NS_ERROR_FAILURE;
|
NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +82,7 @@ nsAndroidHandlerApp::Share(const nsAString & data, const nsAString & title)
|
|||||||
if (!mozilla::AndroidBridge::Bridge())
|
if (!mozilla::AndroidBridge::Bridge())
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
return mozilla::AndroidBridge::Bridge()->
|
return GeckoAppShell::OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType), mPackageName,
|
||||||
OpenUriExternal(data, NS_ConvertUTF8toUTF16(mMimeType), mPackageName,
|
|
||||||
mClassName, mAction) ? NS_OK : NS_ERROR_FAILURE;
|
mClassName, mAction) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ nsExternalSharingAppService::ShareWithDefault(const nsAString & data,
|
|||||||
NS_NAMED_LITERAL_STRING(sendAction, "android.intent.action.SEND");
|
NS_NAMED_LITERAL_STRING(sendAction, "android.intent.action.SEND");
|
||||||
const nsString emptyString = EmptyString();
|
const nsString emptyString = EmptyString();
|
||||||
if (AndroidBridge::Bridge())
|
if (AndroidBridge::Bridge())
|
||||||
return AndroidBridge::Bridge()->
|
return GeckoAppShell::OpenUriExternal(data, mime,
|
||||||
OpenUriExternal(data, mime,
|
emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
emptyString,emptyString, sendAction, title) ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "nsStringEnumerator.h"
|
#include "nsStringEnumerator.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS2(nsMIMEInfoAndroid, nsIMIMEInfo, nsIHandlerInfo)
|
NS_IMPL_ISUPPORTS2(nsMIMEInfoAndroid, nsIMIMEInfo, nsIHandlerInfo)
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
@@ -29,8 +31,7 @@ nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI)
|
|||||||
aURI->GetScheme(uriScheme);
|
aURI->GetScheme(uriScheme);
|
||||||
|
|
||||||
if (mozilla::AndroidBridge::Bridge())
|
if (mozilla::AndroidBridge::Bridge())
|
||||||
return mozilla::AndroidBridge::Bridge()->
|
return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ? EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,13 +39,8 @@
|
|||||||
#include "mozilla/ClearOnShutdown.h"
|
#include "mozilla/ClearOnShutdown.h"
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define ALOG_BRIDGE(args...) ALOG(args)
|
|
||||||
#else
|
|
||||||
#define ALOG_BRIDGE(args...) ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
using namespace mozilla::gfx;
|
using namespace mozilla::gfx;
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS0(nsFilePickerCallback)
|
NS_IMPL_ISUPPORTS0(nsFilePickerCallback)
|
||||||
@@ -170,14 +165,13 @@ AndroidBridge::Init(JNIEnv *jEnv)
|
|||||||
|
|
||||||
mJNIEnv = nullptr;
|
mJNIEnv = nullptr;
|
||||||
mThread = -1;
|
mThread = -1;
|
||||||
mGLControllerObj = nullptr;
|
mGLControllerObj = NULL;
|
||||||
mOpenedGraphicsLibraries = false;
|
mOpenedGraphicsLibraries = false;
|
||||||
mHasNativeBitmapAccess = false;
|
mHasNativeBitmapAccess = false;
|
||||||
mHasNativeWindowAccess = false;
|
mHasNativeWindowAccess = false;
|
||||||
mHasNativeWindowFallback = false;
|
mHasNativeWindowFallback = false;
|
||||||
|
|
||||||
initInit();
|
initInit();
|
||||||
InitStubs(jEnv);
|
|
||||||
|
|
||||||
#ifdef MOZ_WEBSMS_BACKEND
|
#ifdef MOZ_WEBSMS_BACKEND
|
||||||
mAndroidSmsMessageClass = getClassGlobalRef("android/telephony/SmsMessage");
|
mAndroidSmsMessageClass = getClassGlobalRef("android/telephony/SmsMessage");
|
||||||
@@ -272,6 +266,52 @@ jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const nsACString&
|
|||||||
return NewJavaString(frame, NS_ConvertUTF8toUTF16(string));
|
return NewJavaString(frame, NS_ConvertUTF8toUTF16(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
__attribute__ ((visibility("default")))
|
||||||
|
JNIEnv * GetJNIForThread()
|
||||||
|
{
|
||||||
|
JNIEnv *jEnv = NULL;
|
||||||
|
JavaVM *jVm = mozilla::AndroidBridge::GetVM();
|
||||||
|
if (!jVm) {
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Returned a null VM");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
jEnv = static_cast<JNIEnv*>(PR_GetThreadPrivate(sJavaEnvThreadIndex));
|
||||||
|
|
||||||
|
if (jEnv)
|
||||||
|
return jEnv;
|
||||||
|
|
||||||
|
int status = jVm->GetEnv((void**) &jEnv, JNI_VERSION_1_2);
|
||||||
|
if (status) {
|
||||||
|
|
||||||
|
status = jVm->AttachCurrentThread(&jEnv, NULL);
|
||||||
|
if (status) {
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Could not attach");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
PR_SetThreadPrivate(sJavaEnvThreadIndex, jEnv);
|
||||||
|
}
|
||||||
|
if (!jEnv) {
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "returning NULL");
|
||||||
|
}
|
||||||
|
return jEnv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutoGlobalWrappedJavaObject::Dispose() {
|
||||||
|
if (isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetJNIForThread()->DeleteGlobalRef(wrapped_obj);
|
||||||
|
wrapped_obj = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoGlobalWrappedJavaObject::~AutoGlobalWrappedJavaObject() {
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
getHandlersFromStringArray(JNIEnv *aJNIEnv, jobjectArray jArr, jsize aLen,
|
getHandlersFromStringArray(JNIEnv *aJNIEnv, jobjectArray jArr, jsize aLen,
|
||||||
nsIMutableArray *aHandlersArray,
|
nsIMutableArray *aHandlersArray,
|
||||||
@@ -311,7 +351,7 @@ AndroidBridge::GetHandlersForMimeType(const nsAString& aMimeType,
|
|||||||
if (!env)
|
if (!env)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
jobjectArray arr = GetHandlersForMimeTypeWrapper(aMimeType, aAction);
|
jobjectArray arr = GeckoAppShell::GetHandlersForMimeTypeWrapper(aMimeType, aAction);
|
||||||
if (!arr)
|
if (!arr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -340,7 +380,7 @@ AndroidBridge::GetHandlersForURL(const nsAString& aURL,
|
|||||||
if (!env)
|
if (!env)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
jobjectArray arr = GetHandlersForURLWrapper(aURL, aAction);
|
jobjectArray arr = GeckoAppShell::GetHandlersForURLWrapper(aURL, aAction);
|
||||||
if (!arr)
|
if (!arr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -365,7 +405,7 @@ AndroidBridge::GetMimeTypeFromExtensions(const nsACString& aFileExt, nsCString&
|
|||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
jstring jstrType = GetMimeTypeFromExtensionsWrapper(NS_ConvertUTF8toUTF16(aFileExt));
|
jstring jstrType = GeckoAppShell::GetMimeTypeFromExtensionsWrapper(NS_ConvertUTF8toUTF16(aFileExt));
|
||||||
if (!jstrType) {
|
if (!jstrType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -384,7 +424,7 @@ AndroidBridge::GetExtensionFromMimeType(const nsACString& aMimeType, nsACString&
|
|||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
jstring jstrExt = GetExtensionFromMimeTypeWrapper(NS_ConvertUTF8toUTF16(aMimeType));
|
jstring jstrExt = GeckoAppShell::GetExtensionFromMimeTypeWrapper(NS_ConvertUTF8toUTF16(aMimeType));
|
||||||
if (!jstrExt) {
|
if (!jstrExt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -403,7 +443,7 @@ AndroidBridge::GetClipboardText(nsAString& aText)
|
|||||||
if (!env)
|
if (!env)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
jstring result = GetClipboardTextWrapper();
|
jstring result = Clipboard::GetClipboardTextWrapper();
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -414,36 +454,6 @@ AndroidBridge::GetClipboardText(nsAString& aText)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidBridge::ClipboardHasText()
|
|
||||||
{
|
|
||||||
ALOG_BRIDGE("AndroidBridge::ClipboardHasText");
|
|
||||||
|
|
||||||
JNIEnv *env = GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
|
|
||||||
jstring jStr = GetClipboardTextWrapper();
|
|
||||||
bool ret = jStr;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidBridge::EmptyClipboard()
|
|
||||||
{
|
|
||||||
ALOG_BRIDGE("AndroidBridge::EmptyClipboard");
|
|
||||||
|
|
||||||
JNIEnv *env = GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env, 0);
|
|
||||||
env->CallStaticVoidMethod(mClipboardClass, jSetClipboardText, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidBridge::ShowAlertNotification(const nsAString& aImageUrl,
|
AndroidBridge::ShowAlertNotification(const nsAString& aImageUrl,
|
||||||
const nsAString& aAlertTitle,
|
const nsAString& aAlertTitle,
|
||||||
@@ -457,7 +467,7 @@ AndroidBridge::ShowAlertNotification(const nsAString& aImageUrl,
|
|||||||
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeAddObserver(aAlertName, aAlertListener));
|
nsAppShell::gAppShell->PostEvent(AndroidGeckoEvent::MakeAddObserver(aAlertName, aAlertListener));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowAlertNotificationWrapper(aImageUrl, aAlertTitle, aAlertText, aAlertCookie, aAlertName);
|
GeckoAppShell::ShowAlertNotificationWrapper(aImageUrl, aAlertTitle, aAlertText, aAlertCookie, aAlertName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -469,7 +479,7 @@ AndroidBridge::GetDPI()
|
|||||||
|
|
||||||
const int DEFAULT_DPI = 160;
|
const int DEFAULT_DPI = 160;
|
||||||
|
|
||||||
sDPI = GetDpiWrapper();
|
sDPI = GeckoAppShell::GetDpiWrapper();
|
||||||
if (!sDPI) {
|
if (!sDPI) {
|
||||||
return DEFAULT_DPI;
|
return DEFAULT_DPI;
|
||||||
}
|
}
|
||||||
@@ -488,7 +498,7 @@ AndroidBridge::GetScreenDepth()
|
|||||||
|
|
||||||
const int DEFAULT_DEPTH = 16;
|
const int DEFAULT_DEPTH = 16;
|
||||||
|
|
||||||
sDepth = GetScreenDepthWrapper();
|
sDepth = GeckoAppShell::GetScreenDepthWrapper();
|
||||||
if (!sDepth)
|
if (!sDepth)
|
||||||
return DEFAULT_DEPTH;
|
return DEFAULT_DEPTH;
|
||||||
|
|
||||||
@@ -502,7 +512,7 @@ AndroidBridge::ShowFilePickerForExtensions(nsAString& aFilePath, const nsAString
|
|||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
jstring jstr = ShowFilePickerForExtensionsWrapper(aExtensions);
|
jstring jstr = GeckoAppShell::ShowFilePickerForExtensionsWrapper(aExtensions);
|
||||||
if (jstr == nullptr) {
|
if (jstr == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -518,7 +528,7 @@ AndroidBridge::ShowFilePickerForMimeType(nsAString& aFilePath, const nsAString&
|
|||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
jstring jstr = ShowFilePickerForMimeTypeWrapper(aMimeType);
|
jstring jstr = GeckoAppShell::ShowFilePickerForMimeTypeWrapper(aMimeType);
|
||||||
if (jstr == nullptr) {
|
if (jstr == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -531,19 +541,7 @@ void
|
|||||||
AndroidBridge::ShowFilePickerAsync(const nsAString& aMimeType, nsFilePickerCallback* callback)
|
AndroidBridge::ShowFilePickerAsync(const nsAString& aMimeType, nsFilePickerCallback* callback)
|
||||||
{
|
{
|
||||||
callback->AddRef();
|
callback->AddRef();
|
||||||
ShowFilePickerAsyncWrapper(aMimeType, (int64_t) callback);
|
GeckoAppShell::ShowFilePickerAsyncWrapper(aMimeType, (int64_t) callback);
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidBridge::HideProgressDialogOnce()
|
|
||||||
{
|
|
||||||
static bool once = false;
|
|
||||||
if (once)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HideProgressDialog();
|
|
||||||
|
|
||||||
once = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -571,7 +569,7 @@ AndroidBridge::Vibrate(const nsTArray<uint32_t>& aPattern)
|
|||||||
ALOG_BRIDGE(" invalid vibration duration < 0");
|
ALOG_BRIDGE(" invalid vibration duration < 0");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Vibrate1(d);
|
GeckoAppShell::Vibrate1(d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +595,7 @@ AndroidBridge::Vibrate(const nsTArray<uint32_t>& aPattern)
|
|||||||
}
|
}
|
||||||
env->ReleaseLongArrayElements(array, elts, 0);
|
env->ReleaseLongArrayElements(array, elts, 0);
|
||||||
|
|
||||||
VibrateA(array, -1/*don't repeat*/);
|
GeckoAppShell::VibrateA(array, -1/*don't repeat*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -614,7 +612,7 @@ AndroidBridge::GetSystemColors(AndroidSystemColors *aColors)
|
|||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
|
|
||||||
jintArray arr = GetSystemColoursWrapper();
|
jintArray arr = GeckoAppShell::GetSystemColoursWrapper();
|
||||||
if (!arr)
|
if (!arr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -652,7 +650,7 @@ AndroidBridge::GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSiz
|
|||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
|
|
||||||
jbyteArray arr = GetIconForExtensionWrapper(NS_ConvertUTF8toUTF16(aFileExt), aIconSize);
|
jbyteArray arr = GeckoAppShell::GetIconForExtensionWrapper(NS_ConvertUTF8toUTF16(aFileExt), aIconSize);
|
||||||
|
|
||||||
NS_ASSERTION(arr != nullptr, "AndroidBridge::GetIconForExtension: Returned pixels array is null!");
|
NS_ASSERTION(arr != nullptr, "AndroidBridge::GetIconForExtension: Returned pixels array is null!");
|
||||||
if (!arr)
|
if (!arr)
|
||||||
@@ -680,14 +678,11 @@ AndroidBridge::SetLayerClient(JNIEnv* env, jobject jobj)
|
|||||||
|
|
||||||
if (resetting) {
|
if (resetting) {
|
||||||
// clear out the old layer client
|
// clear out the old layer client
|
||||||
env->DeleteGlobalRef(mLayerClient->wrappedObject());
|
|
||||||
delete mLayerClient;
|
delete mLayerClient;
|
||||||
mLayerClient = nullptr;
|
mLayerClient = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidGeckoLayerClient *client = new AndroidGeckoLayerClient();
|
mLayerClient = GeckoLayerClient::Wrap(jobj);
|
||||||
client->Init(env->NewGlobalRef(jobj));
|
|
||||||
mLayerClient = client;
|
|
||||||
|
|
||||||
if (resetting) {
|
if (resetting) {
|
||||||
// since we are re-linking the new java objects to Gecko, we need to get
|
// since we are re-linking the new java objects to Gecko, we need to get
|
||||||
@@ -700,26 +695,17 @@ AndroidBridge::SetLayerClient(JNIEnv* env, jobject jobj)
|
|||||||
void
|
void
|
||||||
AndroidBridge::RegisterCompositor(JNIEnv *env)
|
AndroidBridge::RegisterCompositor(JNIEnv *env)
|
||||||
{
|
{
|
||||||
ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
|
if (mGLControllerObj != NULL && !mGLControllerObj->isNull()) {
|
||||||
if (mGLControllerObj) {
|
|
||||||
// we already have this set up, no need to do it again
|
// we already have this set up, no need to do it again
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!env) {
|
jobject glController = LayerView::RegisterCompositorWrapper();
|
||||||
env = GetJNIForThread(); // called on the compositor thread
|
|
||||||
}
|
|
||||||
if (!env) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jobject glController = RegisterCompositorWrapper();
|
|
||||||
if (!glController) {
|
if (!glController) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGLControllerObj = env->NewGlobalRef(glController);
|
mGLControllerObj = GLController::Wrap(glController);
|
||||||
env->DeleteLocalRef(glController);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLSurface
|
EGLSurface
|
||||||
@@ -735,7 +721,7 @@ AndroidBridge::CreateEGLSurfaceForCompositor()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject eglSurface = CreateEGLSurfaceForCompositorWrapper(mGLControllerObj);
|
jobject eglSurface = mGLControllerObj->CreateEGLSurfaceForCompositorWrapper();
|
||||||
if (!eglSurface)
|
if (!eglSurface)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -807,11 +793,6 @@ mozilla_AndroidBridge_SetMainThread(pthread_t thr)
|
|||||||
return AndroidBridge::Bridge()->SetMainThread(thr);
|
return AndroidBridge::Bridge()->SetMainThread(thr);
|
||||||
}
|
}
|
||||||
|
|
||||||
jclass GetGeckoAppShellClass()
|
|
||||||
{
|
|
||||||
return mozilla::AndroidBridge::GetGeckoAppShellClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
void*
|
void*
|
||||||
AndroidBridge::GetNativeSurface(JNIEnv* env, jobject surface) {
|
AndroidBridge::GetNativeSurface(JNIEnv* env, jobject surface) {
|
||||||
if (!env || !mHasNativeWindowFallback || !jSurfacePointerField)
|
if (!env || !mHasNativeWindowFallback || !jSurfacePointerField)
|
||||||
@@ -1008,7 +989,7 @@ AndroidBridge::InitCamera(const nsCString& contentType, uint32_t camera, uint32_
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
jintArray arr = InitCameraWrapper(NS_ConvertUTF8toUTF16(contentType), (int32_t) camera, (int32_t) width, (int32_t) height);
|
jintArray arr = GeckoAppShell::InitCameraWrapper(NS_ConvertUTF8toUTF16(contentType), (int32_t) camera, (int32_t) width, (int32_t) height);
|
||||||
|
|
||||||
if (!arr)
|
if (!arr)
|
||||||
return false;
|
return false;
|
||||||
@@ -1039,7 +1020,7 @@ AndroidBridge::GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInf
|
|||||||
|
|
||||||
// To prevent calling too many methods through JNI, the Java method returns
|
// To prevent calling too many methods through JNI, the Java method returns
|
||||||
// an array of double even if we actually want a double and a boolean.
|
// an array of double even if we actually want a double and a boolean.
|
||||||
jdoubleArray arr = GetCurrentBatteryInformationWrapper();
|
jdoubleArray arr = GeckoAppShell::GetCurrentBatteryInformationWrapper();
|
||||||
if (!arr || env->GetArrayLength(arr) != 3) {
|
if (!arr || env->GetArrayLength(arr) != 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1063,7 +1044,7 @@ AndroidBridge::HandleGeckoMessage(const nsAString &aMessage, nsAString &aRet)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
jstring returnMessage = HandleGeckoMessageWrapper(aMessage);
|
jstring returnMessage = GeckoAppShell::HandleGeckoMessageWrapper(aMessage);
|
||||||
|
|
||||||
if (!returnMessage)
|
if (!returnMessage)
|
||||||
return;
|
return;
|
||||||
@@ -1130,7 +1111,7 @@ AndroidBridge::SendMessage(const nsAString& aNumber,
|
|||||||
if (!QueueSmsRequest(aRequest, &requestId))
|
if (!QueueSmsRequest(aRequest, &requestId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SendMessageWrapper(aNumber, aMessage, requestId);
|
GeckoAppShell::SendMessageWrapper(aNumber, aMessage, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1142,7 +1123,7 @@ AndroidBridge::GetMessage(int32_t aMessageId, nsIMobileMessageCallback* aRequest
|
|||||||
if (!QueueSmsRequest(aRequest, &requestId))
|
if (!QueueSmsRequest(aRequest, &requestId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GetMessageWrapper(aMessageId, requestId);
|
GeckoAppShell::GetMessageWrapper(aMessageId, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1154,7 +1135,7 @@ AndroidBridge::DeleteMessage(int32_t aMessageId, nsIMobileMessageCallback* aRequ
|
|||||||
if (!QueueSmsRequest(aRequest, &requestId))
|
if (!QueueSmsRequest(aRequest, &requestId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DeleteMessageWrapper(aMessageId, requestId);
|
GeckoAppShell::DeleteMessageWrapper(aMessageId, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1183,7 +1164,7 @@ AndroidBridge::CreateMessageList(const dom::mobilemessage::SmsFilterData& aFilte
|
|||||||
NewJavaString(&jniFrame, aFilter.numbers()[i]));
|
NewJavaString(&jniFrame, aFilter.numbers()[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateMessageListWrapper(aFilter.startDate(), aFilter.endDate(),
|
GeckoAppShell::CreateMessageListWrapper(aFilter.startDate(), aFilter.endDate(),
|
||||||
numbers, aFilter.numbers().Length(),
|
numbers, aFilter.numbers().Length(),
|
||||||
aFilter.delivery(), aReverse, requestId);
|
aFilter.delivery(), aReverse, requestId);
|
||||||
}
|
}
|
||||||
@@ -1197,7 +1178,7 @@ AndroidBridge::GetNextMessageInList(int32_t aListId, nsIMobileMessageCallback* a
|
|||||||
if (!QueueSmsRequest(aRequest, &requestId))
|
if (!QueueSmsRequest(aRequest, &requestId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GetNextMessageInListWrapper(aListId, requestId);
|
GeckoAppShell::GetNextMessageInListWrapper(aListId, requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1249,7 +1230,7 @@ AndroidBridge::GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInf
|
|||||||
// To prevent calling too many methods through JNI, the Java method returns
|
// To prevent calling too many methods through JNI, the Java method returns
|
||||||
// an array of double even if we actually want a double, two booleans, and an integer.
|
// an array of double even if we actually want a double, two booleans, and an integer.
|
||||||
|
|
||||||
jdoubleArray arr = GetCurrentNetworkInformationWrapper();
|
jdoubleArray arr = GeckoAppShell::GetCurrentNetworkInformationWrapper();
|
||||||
if (!arr || env->GetArrayLength(arr) != 4) {
|
if (!arr || env->GetArrayLength(arr) != 4) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1423,7 @@ AndroidBridge::GetGlobalContextRef() {
|
|||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env, 4);
|
AutoLocalJNIFrame jniFrame(env, 4);
|
||||||
|
|
||||||
jobject context = GetContext();
|
jobject context = GeckoAppShell::GetContext();
|
||||||
if (!context) {
|
if (!context) {
|
||||||
ALOG_BRIDGE("%s: Could not GetContext()", __FUNCTION__);
|
ALOG_BRIDGE("%s: Could not GetContext()", __FUNCTION__);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1493,21 +1474,22 @@ AndroidBridge::UnlockWindow(void* window)
|
|||||||
void
|
void
|
||||||
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
AndroidBridge::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
||||||
{
|
{
|
||||||
AndroidGeckoLayerClient *client = mLayerClient;
|
GeckoLayerClient *client = mLayerClient;
|
||||||
if (!client)
|
if (!client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client->SetFirstPaintViewport(aOffset, aZoom, aCssPageRect);
|
client->SetFirstPaintViewport((float)aOffset.x, (float)aOffset.y, aZoom.scale,
|
||||||
|
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
|
AndroidBridge::SetPageRect(const CSSRect& aCssPageRect)
|
||||||
{
|
{
|
||||||
AndroidGeckoLayerClient *client = mLayerClient;
|
GeckoLayerClient *client = mLayerClient;
|
||||||
if (!client)
|
if (!client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client->SetPageRect(aCssPageRect);
|
client->SetPageRect(aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1515,26 +1497,68 @@ AndroidBridge::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLay
|
|||||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
||||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||||
{
|
{
|
||||||
AndroidGeckoLayerClient *client = mLayerClient;
|
GeckoLayerClient *client = mLayerClient;
|
||||||
if (!client)
|
if (!client) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
client->SyncViewportInfo(aDisplayPort, aDisplayResolution, aLayersUpdated,
|
jobject viewTransformJObj = client->SyncViewportInfo(aDisplayPort.x, aDisplayPort.y,
|
||||||
aScrollOffset, aScale, aFixedLayerMargins,
|
aDisplayPort.width, aDisplayPort.height,
|
||||||
aOffset);
|
aDisplayResolution.scale, aLayersUpdated);
|
||||||
|
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
||||||
|
|
||||||
|
if (!viewTransformJObj) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewTransform* viewTransform = ViewTransform::Wrap(viewTransformJObj);
|
||||||
|
aScrollOffset = ScreenPoint(viewTransform->getx(), viewTransform->gety());
|
||||||
|
aScale.scale = viewTransform->getscale();
|
||||||
|
aFixedLayerMargins.top = viewTransform->getfixedLayerMarginTop();
|
||||||
|
aFixedLayerMargins.right = viewTransform->getfixedLayerMarginRight();
|
||||||
|
aFixedLayerMargins.bottom = viewTransform->getfixedLayerMarginBottom();
|
||||||
|
aFixedLayerMargins.left = viewTransform->getfixedLayerMarginLeft();
|
||||||
|
aOffset.x = viewTransform->getoffsetX();
|
||||||
|
aOffset.y = viewTransform->getoffsetY();
|
||||||
|
delete viewTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
void AndroidBridge::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
||||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
||||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
||||||
{
|
{
|
||||||
AndroidGeckoLayerClient *client = mLayerClient;
|
GeckoLayerClient *client = mLayerClient;
|
||||||
if (!client)
|
if (!client) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
client->SyncFrameMetrics(aScrollOffset, aZoom, aCssPageRect,
|
// convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
|
||||||
aLayersUpdated, aDisplayPort, aDisplayResolution,
|
LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
|
||||||
aIsFirstPaint, aFixedLayerMargins, aOffset);
|
dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
|
||||||
|
LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);
|
||||||
|
|
||||||
|
jobject viewTransformJObj = client->SyncFrameMetrics(aScrollOffset.x, aScrollOffset.y, aZoom,
|
||||||
|
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
|
||||||
|
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
|
||||||
|
aIsFirstPaint);
|
||||||
|
|
||||||
|
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
||||||
|
if (!viewTransformJObj) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ViewTransform* viewTransform = ViewTransform::Wrap(viewTransformJObj);
|
||||||
|
|
||||||
|
aFixedLayerMargins.top = viewTransform->getfixedLayerMarginTop();
|
||||||
|
aFixedLayerMargins.right = viewTransform->getfixedLayerMarginRight();
|
||||||
|
aFixedLayerMargins.bottom = viewTransform->getfixedLayerMarginBottom();
|
||||||
|
aFixedLayerMargins.left = viewTransform->getfixedLayerMarginLeft();
|
||||||
|
|
||||||
|
aOffset.x = viewTransform->getoffsetX();
|
||||||
|
aOffset.y = viewTransform->getoffsetY();
|
||||||
|
|
||||||
|
delete viewTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidBridge::AndroidBridge()
|
AndroidBridge::AndroidBridge()
|
||||||
@@ -1599,45 +1623,12 @@ JavaThreadDetachFunc(void *arg)
|
|||||||
vm->DetachCurrentThread();
|
vm->DetachCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
__attribute__ ((visibility("default")))
|
|
||||||
JNIEnv * GetJNIForThread()
|
|
||||||
{
|
|
||||||
JNIEnv *jEnv = nullptr;
|
|
||||||
JavaVM *jVm = mozilla::AndroidBridge::GetVM();
|
|
||||||
if (!jVm) {
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Returned a null VM");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
jEnv = static_cast<JNIEnv*>(PR_GetThreadPrivate(sJavaEnvThreadIndex));
|
|
||||||
|
|
||||||
if (jEnv)
|
|
||||||
return jEnv;
|
|
||||||
|
|
||||||
int status = jVm->GetEnv((void**) &jEnv, JNI_VERSION_1_2);
|
|
||||||
if (status) {
|
|
||||||
|
|
||||||
status = jVm->AttachCurrentThread(&jEnv, nullptr);
|
|
||||||
if (status) {
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Could not attach");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_SetThreadPrivate(sJavaEnvThreadIndex, jEnv);
|
|
||||||
}
|
|
||||||
if (!jEnv) {
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "returning NULL");
|
|
||||||
}
|
|
||||||
return jEnv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
AndroidBridge::GetScreenOrientation()
|
AndroidBridge::GetScreenOrientation()
|
||||||
{
|
{
|
||||||
ALOG_BRIDGE("AndroidBridge::GetScreenOrientation");
|
ALOG_BRIDGE("AndroidBridge::GetScreenOrientation");
|
||||||
|
|
||||||
int16_t orientation = GetScreenOrientationWrapper();
|
int16_t orientation = GeckoAppShell::GetScreenOrientationWrapper();
|
||||||
|
|
||||||
if (!orientation)
|
if (!orientation)
|
||||||
return dom::eScreenOrientation_None;
|
return dom::eScreenOrientation_None;
|
||||||
@@ -1663,7 +1654,7 @@ AndroidBridge::GetProxyForURI(const nsACString & aSpec,
|
|||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
jstring jstrRet = GetProxyForURIWrapper(NS_ConvertUTF8toUTF16(aSpec),
|
jstring jstrRet = GeckoAppShell::GetProxyForURIWrapper(NS_ConvertUTF8toUTF16(aSpec),
|
||||||
NS_ConvertUTF8toUTF16(aScheme),
|
NS_ConvertUTF8toUTF16(aScheme),
|
||||||
NS_ConvertUTF8toUTF16(aHost),
|
NS_ConvertUTF8toUTF16(aHost),
|
||||||
aPort);
|
aPort);
|
||||||
@@ -1699,7 +1690,7 @@ AndroidBridge::AddPluginView(jobject view, const LayoutDeviceRect& rect, bool is
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CSSRect cssRect = rect / win->GetDefaultScale();
|
CSSRect cssRect = rect / win->GetDefaultScale();
|
||||||
AddPluginViewWrapper(view, cssRect.x, cssRect.y, cssRect.width, cssRect.height, isFullScreen);
|
GeckoAppShell::AddPluginViewWrapper(view, cssRect.x, cssRect.y, cssRect.width, cssRect.height, isFullScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -1716,7 +1707,7 @@ AndroidBridge::GetThreadNameJavaProfiling(uint32_t aThreadId, nsCString & aResul
|
|||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
|
|
||||||
jstring jstrThreadName = GetThreadNameJavaProfilingWrapper(aThreadId);
|
jstring jstrThreadName = GeckoJavaSampler::GetThreadNameJavaProfilingWrapper(aThreadId);
|
||||||
|
|
||||||
if (!jstrThreadName)
|
if (!jstrThreadName)
|
||||||
return false;
|
return false;
|
||||||
@@ -1736,7 +1727,7 @@ AndroidBridge::GetFrameNameJavaProfiling(uint32_t aThreadId, uint32_t aSampleId,
|
|||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
|
|
||||||
jstring jstrSampleName = GetFrameNameJavaProfilingWrapper(aThreadId, aSampleId, aFrameId);
|
jstring jstrSampleName = GeckoJavaSampler::GetFrameNameJavaProfilingWrapper(aThreadId, aSampleId, aFrameId);
|
||||||
|
|
||||||
if (!jstrSampleName)
|
if (!jstrSampleName)
|
||||||
return false;
|
return false;
|
||||||
@@ -1857,21 +1848,72 @@ nsresult AndroidBridge::CaptureThumbnail(nsIDOMWindow *window, int32_t bufW, int
|
|||||||
void
|
void
|
||||||
AndroidBridge::GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort)
|
AndroidBridge::GetDisplayPort(bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ALOG_BRIDGE("Enter: %s", __PRETTY_FUNCTION__);
|
||||||
JNIEnv* env = GetJNIEnv();
|
JNIEnv* env = GetJNIEnv();
|
||||||
if (!env || !mLayerClient)
|
if (!env || !mLayerClient || mLayerClient->isNull()) {
|
||||||
|
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
AutoLocalJNIFrame jniFrame(env, 0);
|
AutoLocalJNIFrame jniFrame(env, 0);
|
||||||
mLayerClient->GetDisplayPort(&jniFrame, aPageSizeUpdate, aIsBrowserContentDisplayed, tabId, metrics, displayPort);
|
|
||||||
|
float x, y, width, height,
|
||||||
|
pageLeft, pageTop, pageRight, pageBottom,
|
||||||
|
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
||||||
|
zoom;
|
||||||
|
metrics->GetX(&x);
|
||||||
|
metrics->GetY(&y);
|
||||||
|
metrics->GetWidth(&width);
|
||||||
|
metrics->GetHeight(&height);
|
||||||
|
metrics->GetPageLeft(&pageLeft);
|
||||||
|
metrics->GetPageTop(&pageTop);
|
||||||
|
metrics->GetPageRight(&pageRight);
|
||||||
|
metrics->GetPageBottom(&pageBottom);
|
||||||
|
metrics->GetCssPageLeft(&cssPageLeft);
|
||||||
|
metrics->GetCssPageTop(&cssPageTop);
|
||||||
|
metrics->GetCssPageRight(&cssPageRight);
|
||||||
|
metrics->GetCssPageBottom(&cssPageBottom);
|
||||||
|
metrics->GetZoom(&zoom);
|
||||||
|
|
||||||
|
ImmutableViewportMetrics jmetrics = ImmutableViewportMetrics(pageLeft, pageTop, pageRight, pageBottom,
|
||||||
|
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
||||||
|
x, y, x + width, y + height,
|
||||||
|
zoom);
|
||||||
|
|
||||||
|
jobject jobj = mLayerClient->GetDisplayPort(aPageSizeUpdate, aIsBrowserContentDisplayed, tabId, jmetrics.wrappedObject());
|
||||||
|
if (!jobj) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DisplayPortMetrics* displayPortMetrics = DisplayPortMetrics::Wrap(jobj);
|
||||||
|
|
||||||
|
AndroidRectF rect(env, displayPortMetrics->getMPosition());
|
||||||
|
if (jniFrame.CheckForException()) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float resolution = displayPortMetrics->getResolution();
|
||||||
|
if (jniFrame.CheckForException()) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*displayPort = new nsAndroidDisplayport(rect, resolution);
|
||||||
|
(*displayPort)->AddRef();
|
||||||
|
|
||||||
|
delete displayPortMetrics;
|
||||||
|
ALOG_BRIDGE("Exit: %s", __PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidBridge::ContentDocumentChanged()
|
AndroidBridge::ContentDocumentChanged()
|
||||||
{
|
{
|
||||||
JNIEnv* env = GetJNIEnv();
|
if (!mLayerClient) {
|
||||||
if (!env || !mLayerClient)
|
|
||||||
return;
|
return;
|
||||||
AutoLocalJNIFrame jniFrame(env, 0);
|
}
|
||||||
mLayerClient->ContentDocumentChanged(&jniFrame);
|
mLayerClient->ContentDocumentChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -1880,25 +1922,48 @@ AndroidBridge::IsContentDocumentDisplayed()
|
|||||||
JNIEnv* env = GetJNIEnv();
|
JNIEnv* env = GetJNIEnv();
|
||||||
if (!env || !mLayerClient)
|
if (!env || !mLayerClient)
|
||||||
return false;
|
return false;
|
||||||
AutoLocalJNIFrame jniFrame(env, 0);
|
|
||||||
return mLayerClient->IsContentDocumentDisplayed(&jniFrame);
|
return mLayerClient->IsContentDocumentDisplayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY)
|
AndroidBridge::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY)
|
||||||
{
|
{
|
||||||
AndroidGeckoLayerClient *client = mLayerClient;
|
GeckoLayerClient *client = mLayerClient;
|
||||||
if (!client)
|
if (!client) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return client->ProgressiveUpdateCallback(aHasPendingNewThebesContent, aDisplayPort, aDisplayResolution, aDrawingCritical, aViewport, aScaleX, aScaleY);
|
jobject progressiveUpdateDataJObj = client->ProgressiveUpdateCallback(aHasPendingNewThebesContent,
|
||||||
|
(float)aDisplayPort.x,
|
||||||
|
(float)aDisplayPort.y,
|
||||||
|
(float)aDisplayPort.width,
|
||||||
|
(float)aDisplayPort.height,
|
||||||
|
aDisplayResolution,
|
||||||
|
!aDrawingCritical);
|
||||||
|
|
||||||
|
NS_ABORT_IF_FALSE(progressiveUpdateDataJObj, "No progressive update data!");
|
||||||
|
|
||||||
|
ProgressiveUpdateData* progressiveUpdateData = ProgressiveUpdateData::Wrap(progressiveUpdateDataJObj);
|
||||||
|
|
||||||
|
aViewport.x = progressiveUpdateData->getx();
|
||||||
|
aViewport.y = progressiveUpdateData->gety();
|
||||||
|
aViewport.width = progressiveUpdateData->getwidth();
|
||||||
|
aViewport.height = progressiveUpdateData->getheight();
|
||||||
|
aScaleX = aScaleY = progressiveUpdateData->getscale();
|
||||||
|
|
||||||
|
bool ret = progressiveUpdateData->getabort();
|
||||||
|
delete progressiveUpdateData;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject
|
NativePanZoomController*
|
||||||
AndroidBridge::SetNativePanZoomController(jobject obj)
|
AndroidBridge::SetNativePanZoomController(jobject obj)
|
||||||
{
|
{
|
||||||
jobject old = mNativePanZoomController;
|
NativePanZoomController* old = mNativePanZoomController;
|
||||||
mNativePanZoomController = obj;
|
mNativePanZoomController = NativePanZoomController::Wrap(obj);
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1910,8 +1975,7 @@ AndroidBridge::RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrame
|
|||||||
CSSToScreenScale resolution = aFrameMetrics.mZoom;
|
CSSToScreenScale resolution = aFrameMetrics.mZoom;
|
||||||
ScreenRect dp = (aFrameMetrics.mDisplayPort + aFrameMetrics.mScrollOffset) * resolution;
|
ScreenRect dp = (aFrameMetrics.mDisplayPort + aFrameMetrics.mScrollOffset) * resolution;
|
||||||
|
|
||||||
RequestContentRepaintWrapper(mNativePanZoomController,
|
mNativePanZoomController->RequestContentRepaintWrapper(dp.x, dp.y, dp.width, dp.height, resolution.scale);
|
||||||
dp.x, dp.y, dp.width, dp.height, resolution.scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1968,7 +2032,7 @@ AndroidBridge::PostDelayedTask(Task* aTask, int aDelayMs)
|
|||||||
// if we're inserting it at the head of the queue, notify Java because
|
// if we're inserting it at the head of the queue, notify Java because
|
||||||
// we need to get a callback at an earlier time than the last scheduled
|
// we need to get a callback at an earlier time than the last scheduled
|
||||||
// callback
|
// callback
|
||||||
PostDelayedCallbackWrapper(mNativePanZoomController, (int64_t)aDelayMs);
|
mNativePanZoomController->PostDelayedCallbackWrapper((int64_t)aDelayMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsCOMArray.h"
|
#include "nsCOMArray.h"
|
||||||
|
|
||||||
#include "AndroidJavaWrappers.h"
|
#include "GeneratedJNIWrappers.h"
|
||||||
|
|
||||||
#include "nsIMutableArray.h"
|
#include "nsIMutableArray.h"
|
||||||
#include "nsIMIMEInfo.h"
|
#include "nsIMIMEInfo.h"
|
||||||
@@ -41,7 +41,6 @@ class nsIObserver;
|
|||||||
extern "C" JNIEnv * GetJNIForThread();
|
extern "C" JNIEnv * GetJNIForThread();
|
||||||
|
|
||||||
extern bool mozilla_AndroidBridge_SetMainThread(pthread_t);
|
extern bool mozilla_AndroidBridge_SetMainThread(pthread_t);
|
||||||
extern jclass GetGeckoAppShellClass();
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class Thread;
|
class Thread;
|
||||||
@@ -49,6 +48,8 @@ class Thread;
|
|||||||
|
|
||||||
typedef void* EGLSurface;
|
typedef void* EGLSurface;
|
||||||
|
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
namespace hal {
|
namespace hal {
|
||||||
@@ -160,10 +161,6 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jclass GetGeckoAppShellClass() {
|
|
||||||
return sBridge->mGeckoAppShellClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The bridge needs to be constructed via ConstructBridge first,
|
// The bridge needs to be constructed via ConstructBridge first,
|
||||||
// and then once the Gecko main thread is spun up (Gecko side),
|
// and then once the Gecko main thread is spun up (Gecko side),
|
||||||
// SetMainThread should be called which will create the JNIEnv for
|
// SetMainThread should be called which will create the JNIEnv for
|
||||||
@@ -183,7 +180,7 @@ public:
|
|||||||
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
|
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
|
||||||
|
|
||||||
void SetLayerClient(JNIEnv* env, jobject jobj);
|
void SetLayerClient(JNIEnv* env, jobject jobj);
|
||||||
AndroidGeckoLayerClient &GetLayerClient() { return *mLayerClient; }
|
GeckoLayerClient* GetLayerClient() { return mLayerClient; }
|
||||||
|
|
||||||
bool GetHandlersForURL(const nsAString& aURL,
|
bool GetHandlersForURL(const nsAString& aURL,
|
||||||
nsIMutableArray* handlersArray = nullptr,
|
nsIMutableArray* handlersArray = nullptr,
|
||||||
@@ -199,10 +196,6 @@ public:
|
|||||||
void GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt);
|
void GetExtensionFromMimeType(const nsACString& aMimeType, nsACString& aFileExt);
|
||||||
|
|
||||||
bool GetClipboardText(nsAString& aText);
|
bool GetClipboardText(nsAString& aText);
|
||||||
|
|
||||||
void EmptyClipboard();
|
|
||||||
|
|
||||||
bool ClipboardHasText();
|
|
||||||
|
|
||||||
void ShowAlertNotification(const nsAString& aImageUrl,
|
void ShowAlertNotification(const nsAString& aImageUrl,
|
||||||
const nsAString& aAlertTitle,
|
const nsAString& aAlertTitle,
|
||||||
@@ -220,8 +213,6 @@ public:
|
|||||||
|
|
||||||
void Vibrate(const nsTArray<uint32_t>& aPattern);
|
void Vibrate(const nsTArray<uint32_t>& aPattern);
|
||||||
|
|
||||||
void HideProgressDialogOnce();
|
|
||||||
|
|
||||||
void GetSystemColors(AndroidSystemColors *aColors);
|
void GetSystemColors(AndroidSystemColors *aColors);
|
||||||
|
|
||||||
void GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf);
|
void GetIconForExtension(const nsACString& aFileExt, uint32_t aIconSize, uint8_t * const aBuf);
|
||||||
@@ -340,7 +331,7 @@ protected:
|
|||||||
JNIEnv *mJNIEnv;
|
JNIEnv *mJNIEnv;
|
||||||
pthread_t mThread;
|
pthread_t mThread;
|
||||||
|
|
||||||
AndroidGeckoLayerClient *mLayerClient;
|
GeckoLayerClient *mLayerClient = NULL;
|
||||||
|
|
||||||
// the android.telephony.SmsMessage class
|
// the android.telephony.SmsMessage class
|
||||||
jclass mAndroidSmsMessageClass;
|
jclass mAndroidSmsMessageClass;
|
||||||
@@ -381,7 +372,7 @@ protected:
|
|||||||
jclass jLayerView;
|
jclass jLayerView;
|
||||||
|
|
||||||
jfieldID jEGLSurfacePointerField;
|
jfieldID jEGLSurfacePointerField;
|
||||||
jobject mGLControllerObj;
|
GLController *mGLControllerObj;
|
||||||
|
|
||||||
// some convinient types to have around
|
// some convinient types to have around
|
||||||
jclass jStringClass;
|
jclass jStringClass;
|
||||||
@@ -405,15 +396,14 @@ protected:
|
|||||||
void (* Region_set)(void* region, void* rect);
|
void (* Region_set)(void* region, void* rect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jobject mNativePanZoomController;
|
NativePanZoomController* mNativePanZoomController;
|
||||||
// This will always be accessed from one thread (the APZC "controller"
|
// This will always be accessed from one thread (the APZC "controller"
|
||||||
// thread, which is the Java UI thread), so we don't need to do locking
|
// thread, which is the Java UI thread), so we don't need to do locking
|
||||||
// to touch it
|
// to touch it
|
||||||
nsTArray<DelayedTask*> mDelayedTaskQueue;
|
nsTArray<DelayedTask*> mDelayedTaskQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#include "GeneratedJNIWrappers.h"
|
NativePanZoomController* SetNativePanZoomController(jobject obj);
|
||||||
jobject SetNativePanZoomController(jobject obj);
|
|
||||||
// GeckoContentController methods
|
// GeckoContentController methods
|
||||||
void RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
|
void RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrameMetrics) MOZ_OVERRIDE;
|
||||||
void HandleDoubleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE;
|
void HandleDoubleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE;
|
||||||
|
|||||||
@@ -17,3 +17,17 @@
|
|||||||
|
|
||||||
#define getStaticMethod(fname, ftype) \
|
#define getStaticMethod(fname, ftype) \
|
||||||
AndroidBridge::GetStaticMethodID(jEnv, jClass, fname, ftype)
|
AndroidBridge::GetStaticMethodID(jEnv, jClass, fname, ftype)
|
||||||
|
|
||||||
|
#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
|
||||||
|
|||||||
@@ -861,10 +861,10 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_init(JNIEnv* env, jobject ins
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(env->NewGlobalRef(instance));
|
NativePanZoomController* oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(instance);
|
||||||
if (oldRef) {
|
if (oldRef && !oldRef->isNull()) {
|
||||||
MOZ_ASSERT(false, "Registering a new NPZC when we already have one");
|
MOZ_ASSERT(false, "Registering a new NPZC when we already have one");
|
||||||
env->DeleteGlobalRef(oldRef);
|
delete oldRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,11 +905,11 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy(JNIEnv* env, jobject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(nullptr);
|
NativePanZoomController* oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(NULL);
|
||||||
if (!oldRef) {
|
if (!oldRef || oldRef->isNull()) {
|
||||||
MOZ_ASSERT(false, "Clearing a non-existent NPZC");
|
MOZ_ASSERT(false, "Clearing a non-existent NPZC");
|
||||||
} else {
|
} else {
|
||||||
env->DeleteGlobalRef(oldRef);
|
delete oldRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,6 @@
|
|||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define ALOG_BRIDGE(args...) ALOG(args)
|
|
||||||
#else
|
|
||||||
#define ALOG_BRIDGE(args...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
jclass __jsjni_GetGlobalClassRef(const char *className);
|
jclass __jsjni_GetGlobalClassRef(const char *className);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,13 @@
|
|||||||
#include "AndroidJavaWrappers.h"
|
#include "AndroidJavaWrappers.h"
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
#include "AndroidBridgeUtilities.h"
|
#include "AndroidBridgeUtilities.h"
|
||||||
#include "nsIAndroidBridge.h"
|
|
||||||
#include "nsIDOMKeyEvent.h"
|
#include "nsIDOMKeyEvent.h"
|
||||||
#include "nsIWidget.h"
|
#include "nsIWidget.h"
|
||||||
#include "mozilla/TouchEvents.h"
|
#include "mozilla/TouchEvents.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
|
|
||||||
jclass AndroidGeckoEvent::jGeckoEventClass = 0;
|
jclass AndroidGeckoEvent::jGeckoEventClass = 0;
|
||||||
jfieldID AndroidGeckoEvent::jActionField = 0;
|
jfieldID AndroidGeckoEvent::jActionField = 0;
|
||||||
@@ -91,49 +91,6 @@ jmethodID AndroidLocation::jGetBearingMethod = 0;
|
|||||||
jmethodID AndroidLocation::jGetSpeedMethod = 0;
|
jmethodID AndroidLocation::jGetSpeedMethod = 0;
|
||||||
jmethodID AndroidLocation::jGetTimeMethod = 0;
|
jmethodID AndroidLocation::jGetTimeMethod = 0;
|
||||||
|
|
||||||
jclass AndroidGeckoLayerClient::jGeckoLayerClientClass = 0;
|
|
||||||
jclass AndroidGeckoLayerClient::jViewportClass = 0;
|
|
||||||
jclass AndroidGeckoLayerClient::jDisplayportClass = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jSetFirstPaintViewport = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jSetPageRect = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jSyncViewportInfoMethod = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jSyncFrameMetricsMethod = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jCreateFrameMethod = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jActivateProgramMethod = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jDeactivateProgramMethod = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jGetDisplayPort = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jContentDocumentChanged = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jIsContentDocumentDisplayed = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jViewportCtor = 0;
|
|
||||||
jfieldID AndroidGeckoLayerClient::jDisplayportPosition = 0;
|
|
||||||
jfieldID AndroidGeckoLayerClient::jDisplayportResolution = 0;
|
|
||||||
jmethodID AndroidGeckoLayerClient::jProgressiveUpdateCallbackMethod = 0;
|
|
||||||
|
|
||||||
jclass AndroidLayerRendererFrame::jLayerRendererFrameClass = 0;
|
|
||||||
jmethodID AndroidLayerRendererFrame::jBeginDrawingMethod = 0;
|
|
||||||
jmethodID AndroidLayerRendererFrame::jDrawBackgroundMethod = 0;
|
|
||||||
jmethodID AndroidLayerRendererFrame::jDrawForegroundMethod = 0;
|
|
||||||
jmethodID AndroidLayerRendererFrame::jEndDrawingMethod = 0;
|
|
||||||
|
|
||||||
jclass AndroidViewTransform::jViewTransformClass = 0;
|
|
||||||
jfieldID AndroidViewTransform::jXField = 0;
|
|
||||||
jfieldID AndroidViewTransform::jYField = 0;
|
|
||||||
jfieldID AndroidViewTransform::jScaleField = 0;
|
|
||||||
jfieldID AndroidViewTransform::jFixedLayerMarginLeft = 0;
|
|
||||||
jfieldID AndroidViewTransform::jFixedLayerMarginTop = 0;
|
|
||||||
jfieldID AndroidViewTransform::jFixedLayerMarginRight = 0;
|
|
||||||
jfieldID AndroidViewTransform::jFixedLayerMarginBottom = 0;
|
|
||||||
jfieldID AndroidViewTransform::jOffsetXField = 0;
|
|
||||||
jfieldID AndroidViewTransform::jOffsetYField = 0;
|
|
||||||
|
|
||||||
jclass AndroidProgressiveUpdateData::jProgressiveUpdateDataClass = 0;
|
|
||||||
jfieldID AndroidProgressiveUpdateData::jXField = 0;
|
|
||||||
jfieldID AndroidProgressiveUpdateData::jYField = 0;
|
|
||||||
jfieldID AndroidProgressiveUpdateData::jWidthField = 0;
|
|
||||||
jfieldID AndroidProgressiveUpdateData::jHeightField = 0;
|
|
||||||
jfieldID AndroidProgressiveUpdateData::jScaleField = 0;
|
|
||||||
jfieldID AndroidProgressiveUpdateData::jShouldAbortField = 0;
|
|
||||||
|
|
||||||
RefCountedJavaObject::~RefCountedJavaObject() {
|
RefCountedJavaObject::~RefCountedJavaObject() {
|
||||||
if (mObject)
|
if (mObject)
|
||||||
GetJNIForThread()->DeleteGlobalRef(mObject);
|
GetJNIForThread()->DeleteGlobalRef(mObject);
|
||||||
@@ -148,10 +105,7 @@ mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv)
|
|||||||
AndroidLocation::InitLocationClass(jEnv);
|
AndroidLocation::InitLocationClass(jEnv);
|
||||||
AndroidRect::InitRectClass(jEnv);
|
AndroidRect::InitRectClass(jEnv);
|
||||||
AndroidRectF::InitRectFClass(jEnv);
|
AndroidRectF::InitRectFClass(jEnv);
|
||||||
AndroidGeckoLayerClient::InitGeckoLayerClientClass(jEnv);
|
InitStubs(jEnv);
|
||||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(jEnv);
|
|
||||||
AndroidViewTransform::InitViewTransformClass(jEnv);
|
|
||||||
AndroidProgressiveUpdateData::InitProgressiveUpdateDataClass(jEnv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -290,82 +244,6 @@ AndroidRectF::InitRectFClass(JNIEnv *jEnv)
|
|||||||
jRightField = getField("right", "F");
|
jRightField = getField("right", "F");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
|
||||||
{
|
|
||||||
initInit();
|
|
||||||
|
|
||||||
jGeckoLayerClientClass = getClassGlobalRef("org/mozilla/gecko/gfx/GeckoLayerClient");
|
|
||||||
|
|
||||||
jProgressiveUpdateCallbackMethod = getMethod("progressiveUpdateCallback",
|
|
||||||
"(ZFFFFFZ)Lorg/mozilla/gecko/gfx/ProgressiveUpdateData;");
|
|
||||||
jSetFirstPaintViewport = getMethod("setFirstPaintViewport", "(FFFFFFF)V");
|
|
||||||
jSetPageRect = getMethod("setPageRect", "(FFFF)V");
|
|
||||||
jSyncViewportInfoMethod = getMethod("syncViewportInfo",
|
|
||||||
"(IIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
|
||||||
jSyncFrameMetricsMethod = getMethod("syncFrameMetrics",
|
|
||||||
"(FFFFFFFZIIIIFZ)Lorg/mozilla/gecko/gfx/ViewTransform;");
|
|
||||||
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
|
|
||||||
jActivateProgramMethod = getMethod("activateProgram", "()V");
|
|
||||||
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
|
|
||||||
jGetDisplayPort = getMethod("getDisplayPort", "(ZZILorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)Lorg/mozilla/gecko/gfx/DisplayPortMetrics;");
|
|
||||||
jContentDocumentChanged = getMethod("contentDocumentChanged", "()V");
|
|
||||||
jIsContentDocumentDisplayed = getMethod("isContentDocumentDisplayed", "()Z");
|
|
||||||
|
|
||||||
jViewportClass = getClassGlobalRef("org/mozilla/gecko/gfx/ImmutableViewportMetrics");
|
|
||||||
jViewportCtor = getMethod("<init>", "(FFFFFFFFFFFFF)V");
|
|
||||||
|
|
||||||
jDisplayportClass = getClassGlobalRef("org/mozilla/gecko/gfx/DisplayPortMetrics");
|
|
||||||
jDisplayportPosition = getField("mPosition", "Landroid/graphics/RectF;");
|
|
||||||
jDisplayportResolution = getField("resolution", "F");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(JNIEnv *jEnv)
|
|
||||||
{
|
|
||||||
initInit();
|
|
||||||
|
|
||||||
jLayerRendererFrameClass = getClassGlobalRef("org/mozilla/gecko/gfx/LayerRenderer$Frame");
|
|
||||||
|
|
||||||
jBeginDrawingMethod = getMethod("beginDrawing", "()V");
|
|
||||||
jDrawBackgroundMethod = getMethod("drawBackground", "()V");
|
|
||||||
jDrawForegroundMethod = getMethod("drawForeground", "()V");
|
|
||||||
jEndDrawingMethod = getMethod("endDrawing", "()V");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidViewTransform::InitViewTransformClass(JNIEnv *jEnv)
|
|
||||||
{
|
|
||||||
initInit();
|
|
||||||
|
|
||||||
jViewTransformClass = getClassGlobalRef("org/mozilla/gecko/gfx/ViewTransform");
|
|
||||||
|
|
||||||
jXField = getField("x", "F");
|
|
||||||
jYField = getField("y", "F");
|
|
||||||
jScaleField = getField("scale", "F");
|
|
||||||
jFixedLayerMarginLeft = getField("fixedLayerMarginLeft", "F");
|
|
||||||
jFixedLayerMarginTop = getField("fixedLayerMarginTop", "F");
|
|
||||||
jFixedLayerMarginRight = getField("fixedLayerMarginRight", "F");
|
|
||||||
jFixedLayerMarginBottom = getField("fixedLayerMarginBottom", "F");
|
|
||||||
jOffsetXField = getField("offsetX", "F");
|
|
||||||
jOffsetYField = getField("offsetY", "F");
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidProgressiveUpdateData::InitProgressiveUpdateDataClass(JNIEnv *jEnv)
|
|
||||||
{
|
|
||||||
initInit();
|
|
||||||
|
|
||||||
jProgressiveUpdateDataClass = getClassGlobalRef("org/mozilla/gecko/gfx/ProgressiveUpdateData");
|
|
||||||
|
|
||||||
jXField = getField("x", "F");
|
|
||||||
jYField = getField("y", "F");
|
|
||||||
jWidthField = getField("width", "F");
|
|
||||||
jHeightField = getField("height", "F");
|
|
||||||
jScaleField = getField("scale", "F");
|
|
||||||
jShouldAbortField = getField("abort", "Z");
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef initInit
|
#undef initInit
|
||||||
#undef initClassGlobalRef
|
#undef initClassGlobalRef
|
||||||
#undef getField
|
#undef getField
|
||||||
@@ -892,461 +770,8 @@ AndroidPoint::Init(JNIEnv *jenv, jobject jobj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::Init(jobject jobj)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
|
||||||
wrapped_obj = jobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidLayerRendererFrame::Init(JNIEnv *env, jobject jobj)
|
|
||||||
{
|
|
||||||
if (!isNull()) {
|
|
||||||
Dispose(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapped_obj = env->NewGlobalRef(jobj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidLayerRendererFrame::Dispose(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
env->DeleteGlobalRef(wrapped_obj);
|
|
||||||
wrapped_obj = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidViewTransform::Init(jobject jobj)
|
|
||||||
{
|
|
||||||
NS_ABORT_IF_FALSE(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
|
||||||
wrapped_obj = jobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidProgressiveUpdateData::Init(jobject jobj)
|
|
||||||
{
|
|
||||||
NS_ABORT_IF_FALSE(wrapped_obj == nullptr, "Init called on non-null wrapped_obj!");
|
|
||||||
wrapped_obj = jobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
|
|
||||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env, 0);
|
|
||||||
return env->CallVoidMethod(wrapped_obj, jSetFirstPaintViewport, (float)aOffset.x, (float)aOffset.y, aZoom.scale,
|
|
||||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::SetPageRect(const CSSRect& aCssPageRect)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "SetPageRect called on null layer client!");
|
|
||||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env, 0);
|
|
||||||
return env->CallVoidMethod(wrapped_obj, jSetPageRect,
|
|
||||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost());
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
|
||||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
|
||||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "SyncViewportInfo called on null layer client!");
|
|
||||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
|
|
||||||
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncViewportInfoMethod,
|
|
||||||
aDisplayPort.x, aDisplayPort.y,
|
|
||||||
aDisplayPort.width, aDisplayPort.height,
|
|
||||||
aDisplayResolution.scale, aLayersUpdated);
|
|
||||||
if (jniFrame.CheckForException())
|
|
||||||
return;
|
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
|
||||||
|
|
||||||
AndroidViewTransform viewTransform;
|
|
||||||
viewTransform.Init(viewTransformJObj);
|
|
||||||
|
|
||||||
aScrollOffset = ScreenPoint(viewTransform.GetX(env), viewTransform.GetY(env));
|
|
||||||
aScale.scale = viewTransform.GetScale(env);
|
|
||||||
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
|
||||||
|
|
||||||
aOffset.x = viewTransform.GetOffsetX(env);
|
|
||||||
aOffset.y = viewTransform.GetOffsetY(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
|
||||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
|
||||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(!isNull(), "SyncFrameMetrics called on null layer client!");
|
|
||||||
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
|
|
||||||
// convert the displayport rect from scroll-relative CSS pixels to document-relative device pixels
|
|
||||||
LayerRect dpUnrounded = aDisplayPort * aDisplayResolution;
|
|
||||||
dpUnrounded += LayerPoint::FromUnknownPoint(aScrollOffset.ToUnknownPoint());
|
|
||||||
LayerIntRect dp = gfx::RoundedToInt(dpUnrounded);
|
|
||||||
|
|
||||||
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jSyncFrameMetricsMethod,
|
|
||||||
aScrollOffset.x, aScrollOffset.y, aZoom,
|
|
||||||
aCssPageRect.x, aCssPageRect.y, aCssPageRect.XMost(), aCssPageRect.YMost(),
|
|
||||||
aLayersUpdated, dp.x, dp.y, dp.width, dp.height, aDisplayResolution.scale,
|
|
||||||
aIsFirstPaint);
|
|
||||||
|
|
||||||
if (jniFrame.CheckForException())
|
|
||||||
return;
|
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
|
|
||||||
|
|
||||||
AndroidViewTransform viewTransform;
|
|
||||||
viewTransform.Init(viewTransformJObj);
|
|
||||||
viewTransform.GetFixedLayerMargins(env, aFixedLayerMargins);
|
|
||||||
aOffset.x = viewTransform.GetOffsetX(env);
|
|
||||||
aOffset.y = viewTransform.GetOffsetY(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidGeckoLayerClient::ProgressiveUpdateCallback(bool aHasPendingNewThebesContent,
|
|
||||||
const LayerRect& aDisplayPort,
|
|
||||||
float aDisplayResolution,
|
|
||||||
bool aDrawingCritical,
|
|
||||||
gfx::Rect& aViewport,
|
|
||||||
float& aScaleX,
|
|
||||||
float& aScaleY)
|
|
||||||
{
|
|
||||||
JNIEnv *env = AndroidBridge::GetJNIEnv();
|
|
||||||
if (!env)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
AutoJObject progressiveUpdateDataJObj(env, env->CallObjectMethod(wrapped_obj,
|
|
||||||
jProgressiveUpdateCallbackMethod,
|
|
||||||
aHasPendingNewThebesContent,
|
|
||||||
(float)aDisplayPort.x,
|
|
||||||
(float)aDisplayPort.y,
|
|
||||||
(float)aDisplayPort.width,
|
|
||||||
(float)aDisplayPort.height,
|
|
||||||
aDisplayResolution,
|
|
||||||
!aDrawingCritical));
|
|
||||||
if (env->ExceptionCheck()) {
|
|
||||||
env->ExceptionDescribe();
|
|
||||||
env->ExceptionClear();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(progressiveUpdateDataJObj, "No progressive update data!");
|
|
||||||
|
|
||||||
AndroidProgressiveUpdateData progressiveUpdateData(progressiveUpdateDataJObj);
|
|
||||||
|
|
||||||
aViewport.x = progressiveUpdateData.GetX(env);
|
|
||||||
aViewport.y = progressiveUpdateData.GetY(env);
|
|
||||||
aViewport.width = progressiveUpdateData.GetWidth(env);
|
|
||||||
aViewport.height = progressiveUpdateData.GetHeight(env);
|
|
||||||
aScaleX = aScaleY = progressiveUpdateData.GetScale(env);
|
|
||||||
|
|
||||||
return progressiveUpdateData.GetShouldAbort(env);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobject ConvertToJavaViewportMetrics(JNIEnv* env, nsIAndroidViewport* metrics) {
|
|
||||||
float x, y, width, height,
|
|
||||||
pageLeft, pageTop, pageRight, pageBottom,
|
|
||||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
|
||||||
zoom;
|
|
||||||
metrics->GetX(&x);
|
|
||||||
metrics->GetY(&y);
|
|
||||||
metrics->GetWidth(&width);
|
|
||||||
metrics->GetHeight(&height);
|
|
||||||
metrics->GetPageLeft(&pageLeft);
|
|
||||||
metrics->GetPageTop(&pageTop);
|
|
||||||
metrics->GetPageRight(&pageRight);
|
|
||||||
metrics->GetPageBottom(&pageBottom);
|
|
||||||
metrics->GetCssPageLeft(&cssPageLeft);
|
|
||||||
metrics->GetCssPageTop(&cssPageTop);
|
|
||||||
metrics->GetCssPageRight(&cssPageRight);
|
|
||||||
metrics->GetCssPageBottom(&cssPageBottom);
|
|
||||||
metrics->GetZoom(&zoom);
|
|
||||||
|
|
||||||
jobject jobj = env->NewObject(AndroidGeckoLayerClient::jViewportClass, AndroidGeckoLayerClient::jViewportCtor,
|
|
||||||
pageLeft, pageTop, pageRight, pageBottom,
|
|
||||||
cssPageLeft, cssPageTop, cssPageRight, cssPageBottom,
|
|
||||||
x, y, x + width, y + height,
|
|
||||||
zoom);
|
|
||||||
return jobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
class nsAndroidDisplayport MOZ_FINAL : public nsIAndroidDisplayport
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
virtual nsresult GetLeft(float *aLeft) { *aLeft = mLeft; return NS_OK; }
|
|
||||||
virtual nsresult GetTop(float *aTop) { *aTop = mTop; return NS_OK; }
|
|
||||||
virtual nsresult GetRight(float *aRight) { *aRight = mRight; return NS_OK; }
|
|
||||||
virtual nsresult GetBottom(float *aBottom) { *aBottom = mBottom; return NS_OK; }
|
|
||||||
virtual nsresult GetResolution(float *aResolution) { *aResolution = mResolution; return NS_OK; }
|
|
||||||
virtual nsresult SetLeft(float aLeft) { mLeft = aLeft; return NS_OK; }
|
|
||||||
virtual nsresult SetTop(float aTop) { mTop = aTop; return NS_OK; }
|
|
||||||
virtual nsresult SetRight(float aRight) { mRight = aRight; return NS_OK; }
|
|
||||||
virtual nsresult SetBottom(float aBottom) { mBottom = aBottom; return NS_OK; }
|
|
||||||
virtual nsresult SetResolution(float aResolution) { mResolution = aResolution; return NS_OK; }
|
|
||||||
|
|
||||||
nsAndroidDisplayport(AndroidRectF aRect, float aResolution):
|
|
||||||
mLeft(aRect.Left()), mTop(aRect.Top()), mRight(aRect.Right()), mBottom(aRect.Bottom()), mResolution(aResolution) {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
~nsAndroidDisplayport() {}
|
|
||||||
float mLeft, mTop, mRight, mBottom, mResolution;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsAndroidDisplayport, nsIAndroidDisplayport)
|
NS_IMPL_ISUPPORTS1(nsAndroidDisplayport, nsIAndroidDisplayport)
|
||||||
|
|
||||||
void createDisplayPort(AutoLocalJNIFrame *jniFrame, jobject jobj, nsIAndroidDisplayport** displayPort) {
|
|
||||||
JNIEnv* env = jniFrame->GetEnv();
|
|
||||||
AndroidRectF rect(env, env->GetObjectField(jobj, AndroidGeckoLayerClient::jDisplayportPosition));
|
|
||||||
if (jniFrame->CheckForException()) return;
|
|
||||||
float resolution = env->GetFloatField(jobj, AndroidGeckoLayerClient::jDisplayportResolution);
|
|
||||||
if (jniFrame->CheckForException()) return;
|
|
||||||
*displayPort = new nsAndroidDisplayport(rect, resolution);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::GetDisplayPort(AutoLocalJNIFrame *jniFrame, bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort)
|
|
||||||
{
|
|
||||||
jobject jmetrics = ConvertToJavaViewportMetrics(jniFrame->GetEnv(), metrics);
|
|
||||||
if (jniFrame->CheckForException()) return;
|
|
||||||
if (!jmetrics)
|
|
||||||
return;
|
|
||||||
jobject jobj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jGetDisplayPort, aPageSizeUpdate, aIsBrowserContentDisplayed, tabId, jmetrics);
|
|
||||||
if (jniFrame->CheckForException()) return;
|
|
||||||
createDisplayPort(jniFrame, jobj, displayPort);
|
|
||||||
(*displayPort)->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidGeckoLayerClient::ContentDocumentChanged(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jContentDocumentChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidGeckoLayerClient::IsContentDocumentDisplayed(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
return jniFrame->GetEnv()->CallBooleanMethod(wrapped_obj, jIsContentDocumentDisplayed);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidGeckoLayerClient::CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jobject frameJObj = jniFrame->GetEnv()->CallObjectMethod(wrapped_obj, jCreateFrameMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
NS_ABORT_IF_FALSE(frameJObj, "No frame object!");
|
|
||||||
|
|
||||||
aFrame.Init(jniFrame->GetEnv(), frameJObj);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidGeckoLayerClient::ActivateProgram(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jActivateProgramMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidGeckoLayerClient::DeactivateProgram(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDeactivateProgramMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidLayerRendererFrame::BeginDrawing(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jBeginDrawingMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidLayerRendererFrame::DrawBackground(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawBackgroundMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidLayerRendererFrame::DrawForeground(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawForegroundMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidLayerRendererFrame::EndDrawing(AutoLocalJNIFrame *jniFrame)
|
|
||||||
{
|
|
||||||
if (!jniFrame || !jniFrame->GetEnv())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
|
|
||||||
if (jniFrame->CheckForException())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidViewTransform::GetX(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jXField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidViewTransform::GetY(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jYField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidViewTransform::GetScale(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jScaleField);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
AndroidViewTransform::GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
aFixedLayerMargins.top = env->GetFloatField(wrapped_obj, jFixedLayerMarginTop);
|
|
||||||
aFixedLayerMargins.right = env->GetFloatField(wrapped_obj, jFixedLayerMarginRight);
|
|
||||||
aFixedLayerMargins.bottom = env->GetFloatField(wrapped_obj, jFixedLayerMarginBottom);
|
|
||||||
aFixedLayerMargins.left = env->GetFloatField(wrapped_obj, jFixedLayerMarginLeft);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidViewTransform::GetOffsetX(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jOffsetXField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidViewTransform::GetOffsetY(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jOffsetYField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidProgressiveUpdateData::GetX(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jXField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidProgressiveUpdateData::GetY(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jYField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidProgressiveUpdateData::GetWidth(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jWidthField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidProgressiveUpdateData::GetHeight(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jHeightField);
|
|
||||||
}
|
|
||||||
|
|
||||||
float
|
|
||||||
AndroidProgressiveUpdateData::GetScale(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return 0.0f;
|
|
||||||
return env->GetFloatField(wrapped_obj, jScaleField);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
AndroidProgressiveUpdateData::GetShouldAbort(JNIEnv *env)
|
|
||||||
{
|
|
||||||
if (!env)
|
|
||||||
return false;
|
|
||||||
return env->GetBooleanField(wrapped_obj, jShouldAbortField);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AndroidRect::Init(JNIEnv *jenv, jobject jobj)
|
AndroidRect::Init(JNIEnv *jenv, jobject jobj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
|
#include "nsIAndroidBridge.h"
|
||||||
#include "mozilla/gfx/Rect.h"
|
#include "mozilla/gfx/Rect.h"
|
||||||
#include "mozilla/dom/Touch.h"
|
#include "mozilla/dom/Touch.h"
|
||||||
#include "mozilla/EventForwards.h"
|
#include "mozilla/EventForwards.h"
|
||||||
@@ -23,21 +24,12 @@
|
|||||||
|
|
||||||
//#define FORCE_ALOG 1
|
//#define FORCE_ALOG 1
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
class nsIAndroidDisplayport;
|
class nsIAndroidDisplayport;
|
||||||
class nsIAndroidViewport;
|
class nsIAndroidViewport;
|
||||||
class nsIWidget;
|
class nsIWidget;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
class AndroidGeckoLayerClient;
|
|
||||||
class AutoLocalJNIFrame;
|
class AutoLocalJNIFrame;
|
||||||
|
|
||||||
void InitAndroidJavaWrappers(JNIEnv *jEnv);
|
void InitAndroidJavaWrappers(JNIEnv *jEnv);
|
||||||
@@ -75,10 +67,10 @@ private:
|
|||||||
class WrappedJavaObject {
|
class WrappedJavaObject {
|
||||||
public:
|
public:
|
||||||
WrappedJavaObject() :
|
WrappedJavaObject() :
|
||||||
wrapped_obj(0)
|
wrapped_obj(NULL)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
WrappedJavaObject(jobject jobj) {
|
WrappedJavaObject(jobject jobj) : wrapped_obj(NULL) {
|
||||||
Init(jobj);
|
Init(jobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +79,39 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isNull() const {
|
bool isNull() const {
|
||||||
return wrapped_obj == 0;
|
return wrapped_obj == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
jobject wrappedObject() const {
|
||||||
|
return wrapped_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
jobject wrapped_obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AutoGlobalWrappedJavaObject : protected WrappedJavaObject{
|
||||||
|
public:
|
||||||
|
AutoGlobalWrappedJavaObject() :
|
||||||
|
wrapped_obj(NULL)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
AutoGlobalWrappedJavaObject(jobject jobj, JNIEnv* env) : wrapped_obj(NULL) {
|
||||||
|
Init(jobj, env);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~AutoGlobalWrappedJavaObject();
|
||||||
|
void Dispose();
|
||||||
|
|
||||||
|
void Init(jobject jobj, JNIEnv* env) {
|
||||||
|
if (!isNull()) {
|
||||||
|
env->DeleteGlobalRef(wrapped_obj);
|
||||||
|
}
|
||||||
|
wrapped_obj = env->NewGlobalRef(jobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isNull() const {
|
||||||
|
return wrapped_obj == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
jobject wrappedObject() const {
|
jobject wrappedObject() const {
|
||||||
@@ -186,128 +210,6 @@ protected:
|
|||||||
static jfieldID jTopField;
|
static jfieldID jTopField;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidViewTransform : public WrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitViewTransformClass(JNIEnv *jEnv);
|
|
||||||
|
|
||||||
void Init(jobject jobj);
|
|
||||||
|
|
||||||
AndroidViewTransform() {}
|
|
||||||
AndroidViewTransform(jobject jobj) { Init(jobj); }
|
|
||||||
|
|
||||||
float GetX(JNIEnv *env);
|
|
||||||
float GetY(JNIEnv *env);
|
|
||||||
float GetScale(JNIEnv *env);
|
|
||||||
void GetFixedLayerMargins(JNIEnv *env, LayerMargin &aFixedLayerMargins);
|
|
||||||
float GetOffsetX(JNIEnv *env);
|
|
||||||
float GetOffsetY(JNIEnv *env);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static jclass jViewTransformClass;
|
|
||||||
static jfieldID jXField;
|
|
||||||
static jfieldID jYField;
|
|
||||||
static jfieldID jScaleField;
|
|
||||||
static jfieldID jFixedLayerMarginLeft;
|
|
||||||
static jfieldID jFixedLayerMarginTop;
|
|
||||||
static jfieldID jFixedLayerMarginRight;
|
|
||||||
static jfieldID jFixedLayerMarginBottom;
|
|
||||||
static jfieldID jOffsetXField;
|
|
||||||
static jfieldID jOffsetYField;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AndroidProgressiveUpdateData : public WrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitProgressiveUpdateDataClass(JNIEnv *jEnv);
|
|
||||||
|
|
||||||
void Init(jobject jobj);
|
|
||||||
|
|
||||||
AndroidProgressiveUpdateData() {}
|
|
||||||
AndroidProgressiveUpdateData(jobject jobj) { Init(jobj); }
|
|
||||||
|
|
||||||
float GetX(JNIEnv *env);
|
|
||||||
float GetY(JNIEnv *env);
|
|
||||||
float GetWidth(JNIEnv *env);
|
|
||||||
float GetHeight(JNIEnv *env);
|
|
||||||
float GetScale(JNIEnv *env);
|
|
||||||
bool GetShouldAbort(JNIEnv *env);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static jclass jProgressiveUpdateDataClass;
|
|
||||||
static jfieldID jXField;
|
|
||||||
static jfieldID jYField;
|
|
||||||
static jfieldID jWidthField;
|
|
||||||
static jfieldID jHeightField;
|
|
||||||
static jfieldID jScaleField;
|
|
||||||
static jfieldID jShouldAbortField;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AndroidLayerRendererFrame : public WrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitLayerRendererFrameClass(JNIEnv *jEnv);
|
|
||||||
|
|
||||||
void Init(JNIEnv *env, jobject jobj);
|
|
||||||
void Dispose(JNIEnv *env);
|
|
||||||
|
|
||||||
bool BeginDrawing(AutoLocalJNIFrame *jniFrame);
|
|
||||||
bool DrawBackground(AutoLocalJNIFrame *jniFrame);
|
|
||||||
bool DrawForeground(AutoLocalJNIFrame *jniFrame);
|
|
||||||
bool EndDrawing(AutoLocalJNIFrame *jniFrame);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static jclass jLayerRendererFrameClass;
|
|
||||||
static jmethodID jBeginDrawingMethod;
|
|
||||||
static jmethodID jDrawBackgroundMethod;
|
|
||||||
static jmethodID jDrawForegroundMethod;
|
|
||||||
static jmethodID jEndDrawingMethod;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AndroidGeckoLayerClient : public WrappedJavaObject {
|
|
||||||
public:
|
|
||||||
static void InitGeckoLayerClientClass(JNIEnv *jEnv);
|
|
||||||
|
|
||||||
void Init(jobject jobj);
|
|
||||||
|
|
||||||
AndroidGeckoLayerClient() {}
|
|
||||||
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); }
|
|
||||||
|
|
||||||
void SetFirstPaintViewport(const LayerIntPoint& aOffset, const CSSToLayerScale& aZoom, const CSSRect& aCssPageRect);
|
|
||||||
void SetPageRect(const CSSRect& aCssPageRect);
|
|
||||||
void SyncViewportInfo(const LayerIntRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
|
||||||
bool aLayersUpdated, ScreenPoint& aScrollOffset, CSSToScreenScale& aScale,
|
|
||||||
LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
|
|
||||||
void SyncFrameMetrics(const ScreenPoint& aScrollOffset, float aZoom, const CSSRect& aCssPageRect,
|
|
||||||
bool aLayersUpdated, const CSSRect& aDisplayPort, const CSSToLayerScale& aDisplayResolution,
|
|
||||||
bool aIsFirstPaint, LayerMargin& aFixedLayerMargins, ScreenPoint& aOffset);
|
|
||||||
bool ProgressiveUpdateCallback(bool aHasPendingNewThebesContent, const LayerRect& aDisplayPort, float aDisplayResolution, bool aDrawingCritical, gfx::Rect& aViewport, float& aScaleX, float& aScaleY);
|
|
||||||
bool CreateFrame(AutoLocalJNIFrame *jniFrame, AndroidLayerRendererFrame& aFrame);
|
|
||||||
bool ActivateProgram(AutoLocalJNIFrame *jniFrame);
|
|
||||||
bool DeactivateProgram(AutoLocalJNIFrame *jniFrame);
|
|
||||||
void GetDisplayPort(AutoLocalJNIFrame *jniFrame, bool aPageSizeUpdate, bool aIsBrowserContentDisplayed, int32_t tabId, nsIAndroidViewport* metrics, nsIAndroidDisplayport** displayPort);
|
|
||||||
void ContentDocumentChanged(AutoLocalJNIFrame *jniFrame);
|
|
||||||
bool IsContentDocumentDisplayed(AutoLocalJNIFrame *jniFrame);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static jclass jGeckoLayerClientClass;
|
|
||||||
static jmethodID jSetFirstPaintViewport;
|
|
||||||
static jmethodID jSetPageRect;
|
|
||||||
static jmethodID jSyncViewportInfoMethod;
|
|
||||||
static jmethodID jSyncFrameMetricsMethod;
|
|
||||||
static jmethodID jCreateFrameMethod;
|
|
||||||
static jmethodID jActivateProgramMethod;
|
|
||||||
static jmethodID jDeactivateProgramMethod;
|
|
||||||
static jmethodID jGetDisplayPort;
|
|
||||||
static jmethodID jContentDocumentChanged;
|
|
||||||
static jmethodID jIsContentDocumentDisplayed;
|
|
||||||
static jmethodID jProgressiveUpdateCallbackMethod;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static jclass jViewportClass;
|
|
||||||
static jclass jDisplayportClass;
|
|
||||||
static jmethodID jViewportCtor;
|
|
||||||
static jfieldID jDisplayportPosition;
|
|
||||||
static jfieldID jDisplayportResolution;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
// These keycode masks are not defined in android/keycodes.h:
|
// These keycode masks are not defined in android/keycodes.h:
|
||||||
AKEYCODE_ESCAPE = 111,
|
AKEYCODE_ESCAPE = 111,
|
||||||
@@ -433,6 +335,29 @@ enum {
|
|||||||
AMETA_SHIFT_MASK = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON,
|
AMETA_SHIFT_MASK = AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_RIGHT_ON | AMETA_SHIFT_ON,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class nsAndroidDisplayport MOZ_FINAL : public nsIAndroidDisplayport
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
virtual nsresult GetLeft(float *aLeft) { *aLeft = mLeft; return NS_OK; }
|
||||||
|
virtual nsresult GetTop(float *aTop) { *aTop = mTop; return NS_OK; }
|
||||||
|
virtual nsresult GetRight(float *aRight) { *aRight = mRight; return NS_OK; }
|
||||||
|
virtual nsresult GetBottom(float *aBottom) { *aBottom = mBottom; return NS_OK; }
|
||||||
|
virtual nsresult GetResolution(float *aResolution) { *aResolution = mResolution; return NS_OK; }
|
||||||
|
virtual nsresult SetLeft(float aLeft) { mLeft = aLeft; return NS_OK; }
|
||||||
|
virtual nsresult SetTop(float aTop) { mTop = aTop; return NS_OK; }
|
||||||
|
virtual nsresult SetRight(float aRight) { mRight = aRight; return NS_OK; }
|
||||||
|
virtual nsresult SetBottom(float aBottom) { mBottom = aBottom; return NS_OK; }
|
||||||
|
virtual nsresult SetResolution(float aResolution) { mResolution = aResolution; return NS_OK; }
|
||||||
|
|
||||||
|
nsAndroidDisplayport(AndroidRectF aRect, float aResolution):
|
||||||
|
mLeft(aRect.Left()), mTop(aRect.Top()), mRight(aRect.Right()), mBottom(aRect.Bottom()), mResolution(aResolution) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
~nsAndroidDisplayport() {}
|
||||||
|
float mLeft, mTop, mRight, mBottom, mResolution;
|
||||||
|
};
|
||||||
|
|
||||||
class AndroidMotionEvent
|
class AndroidMotionEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "prenv.h"
|
#include "prenv.h"
|
||||||
|
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
#include "AndroidBridgeUtilities.h"
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
@@ -82,20 +83,20 @@ public:
|
|||||||
nsCOMPtr<nsIBrowserTab> tab;
|
nsCOMPtr<nsIBrowserTab> tab;
|
||||||
mBrowserApp->GetBrowserTab(mTabId, getter_AddRefs(tab));
|
mBrowserApp->GetBrowserTab(mTabId, getter_AddRefs(tab));
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
AndroidBridge::Bridge()->SendThumbnail(buffer, mTabId, false);
|
ThumbnailHelper::SendThumbnail(buffer, mTabId, false);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
tab->GetWindow(getter_AddRefs(domWindow));
|
tab->GetWindow(getter_AddRefs(domWindow));
|
||||||
if (!domWindow) {
|
if (!domWindow) {
|
||||||
AndroidBridge::Bridge()->SendThumbnail(buffer, mTabId, false);
|
ThumbnailHelper::SendThumbnail(buffer, mTabId, false);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(mPoints.Length() == 1, "Thumbnail event does not have enough coordinates");
|
NS_ASSERTION(mPoints.Length() == 1, "Thumbnail event does not have enough coordinates");
|
||||||
|
|
||||||
nsresult rv = AndroidBridge::Bridge()->CaptureThumbnail(domWindow, mPoints[0].x, mPoints[0].y, mTabId, buffer);
|
nsresult rv = AndroidBridge::Bridge()->CaptureThumbnail(domWindow, mPoints[0].x, mPoints[0].y, mTabId, buffer);
|
||||||
AndroidBridge::Bridge()->SendThumbnail(buffer, mTabId, NS_SUCCEEDED(rv));
|
ThumbnailHelper::SendThumbnail(buffer, mTabId, NS_SUCCEEDED(rv));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@@ -110,7 +111,7 @@ class WakeLockListener MOZ_FINAL : public nsIDOMMozWakeLockListener {
|
|||||||
NS_DECL_ISUPPORTS;
|
NS_DECL_ISUPPORTS;
|
||||||
|
|
||||||
nsresult Callback(const nsAString& topic, const nsAString& state) {
|
nsresult Callback(const nsAString& topic, const nsAString& state) {
|
||||||
AndroidBridge::Bridge()->NotifyWakeLockChanged(topic, state);
|
GeckoAppShell::NotifyWakeLockChanged(topic, state);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -202,7 +203,7 @@ nsAppShell::Init()
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
bridge->SetSelectedLocale(EmptyString());
|
GeckoAppShell::SetSelectedLocale(EmptyString());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +213,7 @@ nsAppShell::Init()
|
|||||||
rv = Preferences::GetString(PREFNAME_UA_LOCALE, &locale);
|
rv = Preferences::GetString(PREFNAME_UA_LOCALE, &locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
bridge->SetSelectedLocale(locale);
|
GeckoAppShell::SetSelectedLocale(locale);
|
||||||
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
|
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -244,7 +245,7 @@ nsAppShell::Observe(nsISupports* aSubject,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
bridge->SetSelectedLocale(EmptyString());
|
GeckoAppShell::SetSelectedLocale(EmptyString());
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +255,7 @@ nsAppShell::Observe(nsISupports* aSubject,
|
|||||||
locale = Preferences::GetString(PREFNAME_UA_LOCALE);
|
locale = Preferences::GetString(PREFNAME_UA_LOCALE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bridge->SetSelectedLocale(locale);
|
GeckoAppShell::SetSelectedLocale(locale);
|
||||||
|
|
||||||
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
|
mAllowCoalescingTouches = Preferences::GetBool(PREFNAME_COALESCE_TOUCHES, true);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
@@ -600,7 +601,7 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curEvent->AckNeeded()) {
|
if (curEvent->AckNeeded()) {
|
||||||
AndroidBridge::Bridge()->AcknowledgeEvent();
|
GeckoAppShell::AcknowledgeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
EVLOG("nsAppShell: -- done event %p %d", (void*)curEvent.get(), curEvent->Type());
|
EVLOG("nsAppShell: -- done event %p %d", (void*)curEvent.get(), curEvent->Type());
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ nsClipboard::SetData(nsITransferable *aTransferable,
|
|||||||
|
|
||||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||||
if (AndroidBridge::Bridge())
|
if (AndroidBridge::Bridge())
|
||||||
AndroidBridge::Bridge()->SetClipboardText(buffer);
|
Clipboard::SetClipboardText(buffer);
|
||||||
else
|
else
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
|
|||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||||
if (AndroidBridge::Bridge())
|
if (AndroidBridge::Bridge())
|
||||||
AndroidBridge::Bridge()->EmptyClipboard();
|
Clipboard::ClearText();
|
||||||
} else {
|
} else {
|
||||||
ContentChild::GetSingleton()->SendEmptyClipboard();
|
ContentChild::GetSingleton()->SendEmptyClipboard();
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ nsClipboard::HasDataMatchingFlavors(const char **aFlavorList,
|
|||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||||
if (AndroidBridge::Bridge())
|
if (AndroidBridge::Bridge())
|
||||||
*aHasText = AndroidBridge::Bridge()->ClipboardHasText();
|
*aHasText = Clipboard::HasText();
|
||||||
} else {
|
} else {
|
||||||
ContentChild::GetSingleton()->SendClipboardHasText(aHasText);
|
ContentChild::GetSingleton()->SendClipboardHasText(aHasText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ nsIMEPicker::~nsIMEPicker()
|
|||||||
/* void show (); */
|
/* void show (); */
|
||||||
NS_IMETHODIMP nsIMEPicker::Show()
|
NS_IMETHODIMP nsIMEPicker::Show()
|
||||||
{
|
{
|
||||||
AndroidBridge::Bridge()->ShowInputMethodPicker();
|
GeckoAppShell::ShowInputMethodPicker();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ nsLookAndFeel::GetEchoPasswordImpl()
|
|||||||
if (!mInitializedShowPassword) {
|
if (!mInitializedShowPassword) {
|
||||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||||
if (AndroidBridge::Bridge())
|
if (AndroidBridge::Bridge())
|
||||||
mShowPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
|
mShowPassword = GeckoAppShell::GetShowPasswordSetting();
|
||||||
else
|
else
|
||||||
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available!");
|
NS_ASSERTION(AndroidBridge::Bridge() != nullptr, "AndroidBridge is not available!");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ nsScreenAndroid::GetColorDepth(int32_t *aColorDepth)
|
|||||||
void
|
void
|
||||||
nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness)
|
nsScreenAndroid::ApplyMinimumBrightness(uint32_t aBrightness)
|
||||||
{
|
{
|
||||||
AndroidBridge::Bridge()->SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
|
GeckoAppShell::SetKeepScreenOn(aBrightness == BRIGHTNESS_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsScreenManagerAndroid, nsIScreenManager)
|
NS_IMPL_ISUPPORTS1(nsScreenManagerAndroid, nsIScreenManager)
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ using mozilla::unused;
|
|||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
#include "AndroidBridgeUtilities.h"
|
||||||
#include "android_npapi.h"
|
#include "android_npapi.h"
|
||||||
|
|
||||||
#include "imgIEncoder.h"
|
#include "imgIEncoder.h"
|
||||||
@@ -354,7 +355,7 @@ nsWindow::GetDefaultScaleInternal()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (AndroidBridge::Bridge()) {
|
if (AndroidBridge::Bridge()) {
|
||||||
density = AndroidBridge::Bridge()->GetDensity();
|
density = GeckoAppShell::GetDensity();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!density) {
|
if (!density) {
|
||||||
@@ -519,7 +520,7 @@ nsWindow::SetSizeMode(int32_t aMode)
|
|||||||
{
|
{
|
||||||
switch (aMode) {
|
switch (aMode) {
|
||||||
case nsSizeMode_Minimized:
|
case nsSizeMode_Minimized:
|
||||||
AndroidBridge::Bridge()->MoveTaskToBack();
|
GeckoAppShell::MoveTaskToBack();
|
||||||
break;
|
break;
|
||||||
case nsSizeMode_Fullscreen:
|
case nsSizeMode_Fullscreen:
|
||||||
MakeFullScreen(true);
|
MakeFullScreen(true);
|
||||||
@@ -700,7 +701,7 @@ nsWindow::DispatchEvent(WidgetGUIEvent* aEvent)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindow::MakeFullScreen(bool aFullScreen)
|
nsWindow::MakeFullScreen(bool aFullScreen)
|
||||||
{
|
{
|
||||||
AndroidBridge::Bridge()->SetFullScreen(aFullScreen);
|
GeckoAppShell::SetFullScreen(aFullScreen);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1217,7 +1218,7 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
|
|||||||
// if this event is a down event, that means it's the start of a new block, and the
|
// if this event is a down event, that means it's the start of a new block, and the
|
||||||
// previous block should not be default-prevented
|
// previous block should not be default-prevented
|
||||||
bool defaultPrevented = isDownEvent ? false : preventDefaultActions;
|
bool defaultPrevented = isDownEvent ? false : preventDefaultActions;
|
||||||
AndroidBridge::Bridge()->NotifyDefaultPrevented(defaultPrevented);
|
GeckoAppShell::NotifyDefaultPrevented(defaultPrevented);
|
||||||
sDefaultPreventedNotified = true;
|
sDefaultPreventedNotified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1226,7 +1227,7 @@ bool nsWindow::OnMultitouchEvent(AndroidGeckoEvent *ae)
|
|||||||
// for the next event.
|
// for the next event.
|
||||||
if (isDownEvent) {
|
if (isDownEvent) {
|
||||||
if (preventDefaultActions) {
|
if (preventDefaultActions) {
|
||||||
AndroidBridge::Bridge()->NotifyDefaultPrevented(true);
|
GeckoAppShell::NotifyDefaultPrevented(true);
|
||||||
sDefaultPreventedNotified = true;
|
sDefaultPreventedNotified = true;
|
||||||
} else {
|
} else {
|
||||||
sDefaultPreventedNotified = false;
|
sDefaultPreventedNotified = false;
|
||||||
@@ -1835,10 +1836,10 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
NotifyIMEOfTextChange(0, INT32_MAX / 2, INT32_MAX / 2);
|
NotifyIMEOfTextChange(0, INT32_MAX / 2, INT32_MAX / 2);
|
||||||
FlushIMEChanges();
|
FlushIMEChanges();
|
||||||
}
|
}
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||||
return;
|
return;
|
||||||
} else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
|
} else if (ae->Action() == AndroidGeckoEvent::IME_UPDATE_CONTEXT) {
|
||||||
AndroidBridge::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
GeckoAppShell::NotifyIMEContext(mInputContext.mIMEState.mEnabled,
|
||||||
mInputContext.mHTMLInputType,
|
mInputContext.mHTMLInputType,
|
||||||
mInputContext.mHTMLInputInputmode,
|
mInputContext.mHTMLInputInputmode,
|
||||||
mInputContext.mActionHint);
|
mInputContext.mActionHint);
|
||||||
@@ -1849,7 +1850,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
// Still reply to events, but don't do anything else
|
// Still reply to events, but don't do anything else
|
||||||
if (ae->Action() == AndroidGeckoEvent::IME_SYNCHRONIZE ||
|
if (ae->Action() == AndroidGeckoEvent::IME_SYNCHRONIZE ||
|
||||||
ae->Action() == AndroidGeckoEvent::IME_REPLACE_TEXT) {
|
ae->Action() == AndroidGeckoEvent::IME_REPLACE_TEXT) {
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1862,7 +1863,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
case AndroidGeckoEvent::IME_SYNCHRONIZE:
|
case AndroidGeckoEvent::IME_SYNCHRONIZE:
|
||||||
{
|
{
|
||||||
FlushIMEChanges();
|
FlushIMEChanges();
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AndroidGeckoEvent::IME_REPLACE_TEXT:
|
case AndroidGeckoEvent::IME_REPLACE_TEXT:
|
||||||
@@ -1894,7 +1895,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
}
|
}
|
||||||
mIMEKeyEvents.Clear();
|
mIMEKeyEvents.Clear();
|
||||||
FlushIMEChanges();
|
FlushIMEChanges();
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1916,7 +1917,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae)
|
|||||||
DispatchEvent(&event);
|
DispatchEvent(&event);
|
||||||
}
|
}
|
||||||
FlushIMEChanges();
|
FlushIMEChanges();
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_REPLY_EVENT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AndroidGeckoEvent::IME_SET_SELECTION:
|
case AndroidGeckoEvent::IME_SET_SELECTION:
|
||||||
@@ -2096,7 +2097,7 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
|||||||
case REQUEST_TO_COMMIT_COMPOSITION:
|
case REQUEST_TO_COMMIT_COMPOSITION:
|
||||||
//ALOGIME("IME: REQUEST_TO_COMMIT_COMPOSITION: s=%d", aState);
|
//ALOGIME("IME: REQUEST_TO_COMMIT_COMPOSITION: s=%d", aState);
|
||||||
RemoveIMEComposition();
|
RemoveIMEComposition();
|
||||||
AndroidBridge::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
GeckoAppShell::NotifyIME(REQUEST_TO_COMMIT_COMPOSITION);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case REQUEST_TO_CANCEL_COMPOSITION:
|
case REQUEST_TO_CANCEL_COMPOSITION:
|
||||||
ALOGIME("IME: REQUEST_TO_CANCEL_COMPOSITION");
|
ALOGIME("IME: REQUEST_TO_CANCEL_COMPOSITION");
|
||||||
@@ -2115,11 +2116,11 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
|||||||
DispatchEvent(&compEvent);
|
DispatchEvent(&compEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidBridge::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
GeckoAppShell::NotifyIME(REQUEST_TO_CANCEL_COMPOSITION);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case NOTIFY_IME_OF_FOCUS:
|
case NOTIFY_IME_OF_FOCUS:
|
||||||
ALOGIME("IME: NOTIFY_IME_OF_FOCUS");
|
ALOGIME("IME: NOTIFY_IME_OF_FOCUS");
|
||||||
AndroidBridge::NotifyIME(NOTIFY_IME_OF_FOCUS);
|
GeckoAppShell::NotifyIME(NOTIFY_IME_OF_FOCUS);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case NOTIFY_IME_OF_BLUR:
|
case NOTIFY_IME_OF_BLUR:
|
||||||
ALOGIME("IME: NOTIFY_IME_OF_BLUR");
|
ALOGIME("IME: NOTIFY_IME_OF_BLUR");
|
||||||
@@ -2131,7 +2132,7 @@ nsWindow::NotifyIME(NotificationToIME aNotification)
|
|||||||
mIMEComposing = false;
|
mIMEComposing = false;
|
||||||
mIMEComposingText.Truncate();
|
mIMEComposingText.Truncate();
|
||||||
|
|
||||||
AndroidBridge::NotifyIME(NOTIFY_IME_OF_BLUR);
|
GeckoAppShell::NotifyIME(NOTIFY_IME_OF_BLUR);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case NOTIFY_IME_OF_SELECTION_CHANGE:
|
case NOTIFY_IME_OF_SELECTION_CHANGE:
|
||||||
if (mIMEMaskSelectionUpdate) {
|
if (mIMEMaskSelectionUpdate) {
|
||||||
@@ -2191,7 +2192,7 @@ nsWindow::SetInputContext(const InputContext& aContext,
|
|||||||
|
|
||||||
if (enabled == IMEState::ENABLED && aAction.UserMightRequestOpenVKB()) {
|
if (enabled == IMEState::ENABLED && aAction.UserMightRequestOpenVKB()) {
|
||||||
// Don't reset keyboard when we should simply open the vkb
|
// Don't reset keyboard when we should simply open the vkb
|
||||||
AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_OPEN_VKB);
|
GeckoAppShell::NotifyIME(AndroidBridge::NOTIFY_IME_OPEN_VKB);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2247,7 +2248,7 @@ nsWindow::FlushIMEChanges()
|
|||||||
if (!event.mSucceeded)
|
if (!event.mSucceeded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AndroidBridge::NotifyIMEChange(event.mReply.mString,
|
GeckoAppShell::NotifyIMEChange(event.mReply.mString,
|
||||||
change.mStart,
|
change.mStart,
|
||||||
change.mOldEnd,
|
change.mOldEnd,
|
||||||
change.mNewEnd);
|
change.mNewEnd);
|
||||||
@@ -2262,7 +2263,7 @@ nsWindow::FlushIMEChanges()
|
|||||||
if (!event.mSucceeded)
|
if (!event.mSucceeded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AndroidBridge::NotifyIMEChange(EmptyString(),
|
GeckoAppShell::NotifyIMEChange(EmptyString(),
|
||||||
(int32_t) event.GetSelectionStart(),
|
(int32_t) event.GetSelectionStart(),
|
||||||
(int32_t) event.GetSelectionEnd(), -1);
|
(int32_t) event.GetSelectionEnd(), -1);
|
||||||
mIMESelectionChanged = false;
|
mIMESelectionChanged = false;
|
||||||
@@ -2357,44 +2358,51 @@ nsWindow::DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect)
|
|||||||
{
|
{
|
||||||
JNIEnv *env = GetJNIForThread();
|
JNIEnv *env = GetJNIForThread();
|
||||||
NS_ABORT_IF_FALSE(env, "No JNI environment at DrawWindowUnderlay()!");
|
NS_ABORT_IF_FALSE(env, "No JNI environment at DrawWindowUnderlay()!");
|
||||||
if (!env)
|
if (!env) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
AutoLocalJNIFrame jniFrame(env);
|
||||||
|
|
||||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
GeckoLayerClient* client = AndroidBridge::Bridge()->GetLayerClient();
|
||||||
if (!client.CreateFrame(&jniFrame, mLayerRendererFrame)) return;
|
if (!client || client->isNull()) {
|
||||||
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
if (!WidgetPaintsBackground())
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!client.ActivateProgram(&jniFrame)) return;
|
jobject frameObj = client->CreateFrame();
|
||||||
if (!mLayerRendererFrame.BeginDrawing(&jniFrame)) return;
|
NS_ABORT_IF_FALSE(frameObj, "No frame object!");
|
||||||
if (!mLayerRendererFrame.DrawBackground(&jniFrame)) return;
|
if (!frameObj) {
|
||||||
if (!client.DeactivateProgram(&jniFrame)) return; // redundant, but in case somebody adds code after this...
|
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mLayerRendererFrame.Init(frameObj, env);
|
||||||
|
if (!WidgetPaintsBackground()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
client->ActivateProgram();
|
||||||
|
mLayerRendererFrame.BeginDrawing();
|
||||||
|
mLayerRendererFrame.DrawBackground();
|
||||||
|
client->DeactivateProgram(); // redundant, but in case somebody adds code after this...
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
|
nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect)
|
||||||
{
|
{
|
||||||
PROFILER_LABEL("nsWindow", "DrawWindowOverlay");
|
PROFILER_LABEL("nsWindow", "DrawWindowOverlay");
|
||||||
JNIEnv *env = GetJNIForThread();
|
|
||||||
NS_ABORT_IF_FALSE(env, "No JNI environment at DrawWindowOverlay()!");
|
|
||||||
if (!env)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AutoLocalJNIFrame jniFrame(env);
|
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(!mLayerRendererFrame.isNull(),
|
NS_ABORT_IF_FALSE(!mLayerRendererFrame.isNull(),
|
||||||
"Frame should have been created in DrawWindowUnderlay()!");
|
"Frame should have been created in DrawWindowUnderlay()!");
|
||||||
|
|
||||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
GeckoLayerClient* client = AndroidBridge::Bridge()->GetLayerClient();
|
||||||
|
|
||||||
if (!client.ActivateProgram(&jniFrame)) return;
|
client->ActivateProgram();
|
||||||
if (!mLayerRendererFrame.DrawForeground(&jniFrame)) return;
|
mLayerRendererFrame.DrawForeground();
|
||||||
if (!mLayerRendererFrame.EndDrawing(&jniFrame)) return;
|
mLayerRendererFrame.EndDrawing();
|
||||||
if (!client.DeactivateProgram(&jniFrame)) return;
|
client->DeactivateProgram();
|
||||||
mLayerRendererFrame.Dispose(env);
|
mLayerRendererFrame.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// off-main-thread compositor fields and functions
|
// off-main-thread compositor fields and functions
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "nsIIdleServiceInternal.h"
|
#include "nsIIdleServiceInternal.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include "AndroidJavaWrappers.h"
|
#include "AndroidJavaWrappers.h"
|
||||||
|
#include "GeneratedJNIWrappers.h"
|
||||||
#include "mozilla/EventForwards.h"
|
#include "mozilla/EventForwards.h"
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
#include "mozilla/TextRange.h"
|
#include "mozilla/TextRange.h"
|
||||||
@@ -240,7 +241,7 @@ private:
|
|||||||
void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
|
void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
|
||||||
void RedrawAll();
|
void RedrawAll();
|
||||||
|
|
||||||
mozilla::AndroidLayerRendererFrame mLayerRendererFrame;
|
mozilla::widget::android::LayerRendererFrame mLayerRendererFrame;
|
||||||
|
|
||||||
static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
|
static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
|
||||||
static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
|
static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#ifdef MOZ_WIDGET_ANDROID
|
#ifdef MOZ_WIDGET_ANDROID
|
||||||
#include "AndroidBridge.h"
|
#include "AndroidBridge.h"
|
||||||
|
using namespace mozilla::widget::android;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GONK
|
#ifdef MOZ_WIDGET_GONK
|
||||||
@@ -229,7 +230,7 @@ nsSystemInfo::Init()
|
|||||||
android_sdk_version = version;
|
android_sdk_version = version;
|
||||||
if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str))
|
if (version >= 8 && mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build", "HARDWARE", str))
|
||||||
SetPropertyAsAString(NS_LITERAL_STRING("hardware"), str);
|
SetPropertyAsAString(NS_LITERAL_STRING("hardware"), str);
|
||||||
bool isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
|
bool isTablet = GeckoAppShell::IsTablet();
|
||||||
SetPropertyAsBool(NS_LITERAL_STRING("tablet"), isTablet);
|
SetPropertyAsBool(NS_LITERAL_STRING("tablet"), isTablet);
|
||||||
// NSPR "version" is the kernel version. For Android we want the Android version.
|
// NSPR "version" is the kernel version. For Android we want the Android version.
|
||||||
// Rename SDK version to version and put the kernel version into kernel_version.
|
// Rename SDK version to version and put the kernel version into kernel_version.
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ ParseManifest(NSLocationType type, FileLocation &file, char* buf, bool aChromeOn
|
|||||||
bool isTablet = false;
|
bool isTablet = false;
|
||||||
if (mozilla::AndroidBridge::Bridge()) {
|
if (mozilla::AndroidBridge::Bridge()) {
|
||||||
mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", osVersion);
|
mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", osVersion);
|
||||||
isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
|
isTablet = mozilla::widget::android::GeckoAppShell::IsTablet();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1845,8 +1845,7 @@ nsLocalFile::Launch()
|
|||||||
|
|
||||||
nsDependentCString fileUri = NS_LITERAL_CSTRING("file://");
|
nsDependentCString fileUri = NS_LITERAL_CSTRING("file://");
|
||||||
fileUri.Append(mPath);
|
fileUri.Append(mPath);
|
||||||
mozilla::AndroidBridge* bridge = mozilla::AndroidBridge::Bridge();
|
return GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(fileUri), NS_ConvertUTF8toUTF16(type)) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
return bridge->OpenUriExternal(NS_ConvertUTF8toUTF16(fileUri), NS_ConvertUTF8toUTF16(type)) ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
#elif defined(MOZ_WIDGET_COCOA)
|
#elif defined(MOZ_WIDGET_COCOA)
|
||||||
CFURLRef url;
|
CFURLRef url;
|
||||||
if (NS_SUCCEEDED(GetCFURL(&url))) {
|
if (NS_SUCCEEDED(GetCFURL(&url))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user