mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout 1ca8d5a931ac (bug 720799), e4781b684008 (bug 720795), 8a4e12d93a23 & 1fc8123a2ea4 (bug 720794) for bustage
This commit is contained in:
parent
a9b8806446
commit
7307ed3da9
@ -106,7 +106,6 @@ EXPORTS_NAMESPACES = mozilla/dom
|
||||
EXPORTS_mozilla/dom = \
|
||||
DOMError.h \
|
||||
StructuredCloneTags.h \
|
||||
ScreenOrientation.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -1,62 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ScreenOrientation_h
|
||||
#define mozilla_dom_ScreenOrientation_h
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// Make sure that any change here is also made in
|
||||
// * mobile/android/base/GeckoScreenOrientationListener.java
|
||||
// * embedding/android/GeckoScreenOrientationListener.java
|
||||
enum ScreenOrientation {
|
||||
eScreenOrientation_Current = 0,
|
||||
eScreenOrientation_PortraitPrimary = 1, // 00000001
|
||||
eScreenOrientation_PortraitSecondary = 2, // 00000010
|
||||
eScreenOrientation_Portrait = 3, // 00000011
|
||||
eScreenOrientation_LandscapePrimary = 4, // 00000100
|
||||
eScreenOrientation_LandscapeSecondary = 8, // 00001000
|
||||
eScreenOrientation_Landscape = 12, // 00001100
|
||||
eScreenOrientation_EndGuard
|
||||
};
|
||||
|
||||
/**
|
||||
* ScreenOrientationWrapper is a class wrapping ScreenOrientation so it can be
|
||||
* used with Observer<T> which is taking a class, not an enum.
|
||||
* C++11 should make this useless.
|
||||
*/
|
||||
class ScreenOrientationWrapper {
|
||||
public:
|
||||
ScreenOrientationWrapper()
|
||||
: orientation(eScreenOrientation_Current)
|
||||
{}
|
||||
|
||||
ScreenOrientationWrapper(ScreenOrientation aOrientation)
|
||||
: orientation(aOrientation)
|
||||
{}
|
||||
|
||||
ScreenOrientation orientation;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
namespace IPC {
|
||||
|
||||
/**
|
||||
* Screen orientation serializer.
|
||||
* Note that technically, 5, 6, 7, 9, 10 and 11 are illegal values but will
|
||||
* not make the serializer to fail. We might want to write our own serializer.
|
||||
*/
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::ScreenOrientation>
|
||||
: public EnumSerializer<mozilla::dom::ScreenOrientation,
|
||||
mozilla::dom::eScreenOrientation_Current,
|
||||
mozilla::dom::eScreenOrientation_EndGuard>
|
||||
{};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_dom_ScreenOrientation_h
|
@ -2466,7 +2466,6 @@ nsDOMClassInfo::Init()
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
|
||||
|
@ -1312,11 +1312,6 @@ nsGlobalWindow::FreeInnerObjects(bool aClearScope)
|
||||
mNavigator = nsnull;
|
||||
}
|
||||
|
||||
if (mScreen) {
|
||||
mScreen->Invalidate();
|
||||
mScreen = nsnull;
|
||||
}
|
||||
|
||||
if (mDocument) {
|
||||
NS_ASSERTION(mDoc, "Why is mDoc null?");
|
||||
|
||||
@ -2497,6 +2492,8 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
|
||||
|
||||
if (mFrames)
|
||||
mFrames->SetDocShell(aDocShell);
|
||||
if (mScreen)
|
||||
mScreen->SetDocShell(aDocShell);
|
||||
|
||||
if (!mDocShell) {
|
||||
MaybeForgiveSpamCount();
|
||||
@ -3004,14 +3001,14 @@ nsGlobalWindow::GetNavigator(nsIDOMNavigator** aNavigator)
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetScreen(nsIDOMScreen** aScreen)
|
||||
{
|
||||
FORWARD_TO_INNER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
|
||||
FORWARD_TO_OUTER(GetScreen, (aScreen), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
*aScreen = nsnull;
|
||||
|
||||
if (!mScreen) {
|
||||
mScreen = nsScreen::Create(this);
|
||||
if (!mScreen && mDocShell) {
|
||||
mScreen = new nsScreen(mDocShell);
|
||||
if (!mScreen) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,32 +46,13 @@
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
/* static */ bool nsScreen::sInitialized = false;
|
||||
/* static */ bool nsScreen::sAllowScreenEnabledProperty = false;
|
||||
/* static */ bool nsScreen::sAllowScreenBrightnessProperty = false;
|
||||
|
||||
namespace {
|
||||
|
||||
bool
|
||||
IsChromeType(nsIDocShell *aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
|
||||
if (!ds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PRInt32 itemType;
|
||||
ds->GetItemType(&itemType);
|
||||
return itemType == nsIDocShellTreeItem::typeChrome;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
/* static */ void
|
||||
nsScreen::Initialize()
|
||||
{
|
||||
@ -83,75 +64,42 @@ nsScreen::Initialize()
|
||||
"dom.screenBrightnessProperty.enabled");
|
||||
}
|
||||
|
||||
void
|
||||
nsScreen::Invalidate()
|
||||
{
|
||||
hal::UnregisterScreenOrientationObserver(this);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsScreen>
|
||||
nsScreen::Create(nsPIDOMWindow* aWindow)
|
||||
//
|
||||
// Screen class implementation
|
||||
//
|
||||
nsScreen::nsScreen(nsIDocShell* aDocShell)
|
||||
: mDocShell(aDocShell)
|
||||
{
|
||||
if (!sInitialized) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
if (!aWindow->GetDocShell()) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsRefPtr<nsScreen> screen = new nsScreen();
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(aWindow);
|
||||
NS_ENSURE_TRUE(sgo, nsnull);
|
||||
|
||||
nsCOMPtr<nsIScriptContext> scriptContext = sgo->GetContext();
|
||||
NS_ENSURE_TRUE(scriptContext, nsnull);
|
||||
|
||||
screen->mOwner = aWindow;
|
||||
screen->mScriptContext.swap(scriptContext);
|
||||
screen->mIsChrome = IsChromeType(aWindow->GetDocShell());
|
||||
|
||||
hal::RegisterScreenOrientationObserver(screen);
|
||||
hal::GetCurrentScreenOrientation(&(screen->mOrientation));
|
||||
|
||||
return screen.forget();
|
||||
}
|
||||
|
||||
nsScreen::nsScreen()
|
||||
{
|
||||
}
|
||||
|
||||
nsScreen::~nsScreen()
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
DOMCI_DATA(Screen, nsScreen)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsScreen)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsScreen,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(mozorientationchange)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsScreen,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(mozorientationchange)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
// QueryInterface implementation for nsScreen
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsScreen)
|
||||
NS_INTERFACE_MAP_BEGIN(nsScreen)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMScreen)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScreen)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Screen)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsScreen, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(nsScreen, nsDOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(nsScreen, mozorientationchange)
|
||||
NS_IMPL_ADDREF(nsScreen)
|
||||
NS_IMPL_RELEASE(nsScreen)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreen::SetDocShell(nsIDocShell* aDocShell)
|
||||
{
|
||||
mDocShell = aDocShell; // Weak Reference
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreen::GetTop(PRInt32* aTop)
|
||||
@ -271,7 +219,7 @@ nsScreen::GetAvailTop(PRInt32* aAvailTop)
|
||||
nsDeviceContext*
|
||||
nsScreen::GetDeviceContext()
|
||||
{
|
||||
return nsLayoutUtils::GetDeviceContextForScreenInfo(mOwner);
|
||||
return nsLayoutUtils::GetDeviceContextForScreenInfo(mDocShell);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -312,10 +260,27 @@ nsScreen::GetAvailRect(nsRect& aRect)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool
|
||||
IsChromeType(nsIDocShell *aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
|
||||
if (!ds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PRInt32 itemType;
|
||||
ds->GetItemType(&itemType);
|
||||
return itemType == nsIDocShellTreeItem::typeChrome;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
nsresult
|
||||
nsScreen::GetMozEnabled(bool *aEnabled)
|
||||
{
|
||||
if (!sAllowScreenEnabledProperty || mIsChrome) {
|
||||
if (!sAllowScreenEnabledProperty || !IsChromeType(mDocShell)) {
|
||||
*aEnabled = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -327,7 +292,7 @@ nsScreen::GetMozEnabled(bool *aEnabled)
|
||||
nsresult
|
||||
nsScreen::SetMozEnabled(bool aEnabled)
|
||||
{
|
||||
if (!sAllowScreenEnabledProperty || mIsChrome) {
|
||||
if (!sAllowScreenEnabledProperty || !IsChromeType(mDocShell)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -340,7 +305,7 @@ nsScreen::SetMozEnabled(bool aEnabled)
|
||||
nsresult
|
||||
nsScreen::GetMozBrightness(double *aBrightness)
|
||||
{
|
||||
if (!sAllowScreenBrightnessProperty || mIsChrome) {
|
||||
if (!sAllowScreenBrightnessProperty || !IsChromeType(mDocShell)) {
|
||||
*aBrightness = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -352,7 +317,7 @@ nsScreen::GetMozBrightness(double *aBrightness)
|
||||
nsresult
|
||||
nsScreen::SetMozBrightness(double aBrightness)
|
||||
{
|
||||
if (!sAllowScreenBrightnessProperty || mIsChrome) {
|
||||
if (!sAllowScreenBrightnessProperty || !IsChromeType(mDocShell)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -360,63 +325,3 @@ nsScreen::SetMozBrightness(double aBrightness)
|
||||
hal::SetScreenBrightness(aBrightness);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsScreen::Notify(const ScreenOrientationWrapper& aOrientation)
|
||||
{
|
||||
ScreenOrientation previousOrientation = mOrientation;
|
||||
mOrientation = aOrientation.orientation;
|
||||
|
||||
NS_ASSERTION(mOrientation != eScreenOrientation_Current &&
|
||||
mOrientation != eScreenOrientation_EndGuard &&
|
||||
mOrientation != eScreenOrientation_Portrait &&
|
||||
mOrientation != eScreenOrientation_Landscape,
|
||||
"Invalid orientation value passed to notify method!");
|
||||
|
||||
if (mOrientation != previousOrientation) {
|
||||
// TODO: use an helper method, see bug 720768.
|
||||
nsRefPtr<nsDOMEvent> event = new nsDOMEvent(nsnull, nsnull);
|
||||
nsresult rv = event->InitEvent(NS_LITERAL_STRING("mozorientationchange"), false, false);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
rv = event->SetTrusted(true);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool dummy;
|
||||
rv = DispatchEvent(event, &dummy);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreen::GetMozOrientation(nsAString& aOrientation)
|
||||
{
|
||||
switch (mOrientation) {
|
||||
case eScreenOrientation_Current:
|
||||
case eScreenOrientation_EndGuard:
|
||||
case eScreenOrientation_Portrait:
|
||||
case eScreenOrientation_Landscape:
|
||||
NS_ASSERTION(false, "Shouldn't be used when getting value!");
|
||||
return NS_ERROR_FAILURE;
|
||||
case eScreenOrientation_PortraitPrimary:
|
||||
aOrientation.AssignLiteral("portrait-primary");
|
||||
break;
|
||||
case eScreenOrientation_PortraitSecondary:
|
||||
aOrientation.AssignLiteral("portrait-secondary");
|
||||
break;
|
||||
case eScreenOrientation_LandscapePrimary:
|
||||
aOrientation.AssignLiteral("landscape-primary");
|
||||
break;
|
||||
case eScreenOrientation_LandscapeSecondary:
|
||||
aOrientation.AssignLiteral("landscape-secondary");
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -37,58 +37,40 @@
|
||||
#ifndef nsScreen_h___
|
||||
#define nsScreen_h___
|
||||
|
||||
#include "mozilla/Hal.h"
|
||||
#include "nsIDOMScreen.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "mozilla/Observer.h"
|
||||
|
||||
class nsIDocShell;
|
||||
class nsDeviceContext;
|
||||
struct nsRect;
|
||||
|
||||
// Script "screen" object
|
||||
class nsScreen : public nsDOMEventTargetHelper
|
||||
, public nsIDOMScreen
|
||||
, public mozilla::hal::ScreenOrientationObserver
|
||||
class nsScreen : public nsIDOMScreen
|
||||
{
|
||||
public:
|
||||
static already_AddRefed<nsScreen> Create(nsPIDOMWindow* aWindow);
|
||||
nsScreen(nsIDocShell* aDocShell);
|
||||
virtual ~nsScreen();
|
||||
|
||||
void Invalidate();
|
||||
NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMSCREEN
|
||||
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsScreen,
|
||||
nsDOMEventTargetHelper)
|
||||
|
||||
void Notify(const mozilla::dom::ScreenOrientationWrapper& aOrientation);
|
||||
|
||||
protected:
|
||||
nsDeviceContext* GetDeviceContext();
|
||||
nsresult GetRect(nsRect& aRect);
|
||||
nsresult GetAvailRect(nsRect& aRect);
|
||||
|
||||
bool mIsChrome;
|
||||
|
||||
mozilla::dom::ScreenOrientation mOrientation;
|
||||
nsIDocShell* mDocShell; // Weak Reference
|
||||
|
||||
private:
|
||||
nsScreen();
|
||||
virtual ~nsScreen();
|
||||
|
||||
static bool sInitialized;
|
||||
static bool sAllowScreenEnabledProperty;
|
||||
static bool sAllowScreenBrightnessProperty;
|
||||
|
||||
static void Initialize();
|
||||
|
||||
NS_DECL_EVENT_HANDLER(mozorientationchange)
|
||||
};
|
||||
|
||||
#endif /* nsScreen_h___ */
|
||||
|
@ -91,5 +91,3 @@ XPIDLSRCS = \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
XPIDL_FLAGS += -I$(topsrcdir)/dom/interfaces/events/
|
||||
|
@ -37,10 +37,10 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIDOMEventTarget.idl"
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(6366afc9-0072-4231-a4ec-98cd65f350ef)]
|
||||
interface nsIDOMScreen : nsIDOMEventTarget
|
||||
[scriptable, uuid(4507e43f-097c-452a-bfc4-dbb99748f6fd)]
|
||||
interface nsIDOMScreen : nsISupports
|
||||
{
|
||||
readonly attribute long top;
|
||||
readonly attribute long left;
|
||||
@ -75,13 +75,4 @@ interface nsIDOMScreen : nsIDOMEventTarget
|
||||
* @throw NS_ERROR_INVALID_ARG if brightness is not in the range [0, 1].
|
||||
*/
|
||||
attribute double mozBrightness;
|
||||
|
||||
/**
|
||||
* Returns the current screen orientation.
|
||||
* Can be: landscape-primary, landscape-secondary,
|
||||
* portrait-primary or portrait-secondary.
|
||||
*/
|
||||
readonly attribute DOMString mozOrientation;
|
||||
|
||||
attribute nsIDOMEventListener onmozorientationchange;
|
||||
};
|
||||
|
@ -512,7 +512,6 @@ abstract public class GeckoApp
|
||||
|
||||
unregisterReceiver(mConnectivityReceiver);
|
||||
GeckoNetworkManager.getInstance().stop();
|
||||
GeckoScreenOrientationListener.getInstance().stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -532,7 +531,6 @@ abstract public class GeckoApp
|
||||
|
||||
registerReceiver(mConnectivityReceiver, mConnectivityFilter);
|
||||
GeckoNetworkManager.getInstance().start();
|
||||
GeckoScreenOrientationListener.getInstance().start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -588,7 +586,6 @@ abstract public class GeckoApp
|
||||
}
|
||||
|
||||
GeckoNetworkManager.getInstance().stop();
|
||||
GeckoScreenOrientationListener.getInstance().stop();
|
||||
|
||||
super.onDestroy();
|
||||
|
||||
|
@ -1829,16 +1829,4 @@ public class GeckoAppShell
|
||||
|
||||
// This is only used in Native Fennec.
|
||||
public static void setPreventPanning(final boolean aPreventPanning) { }
|
||||
|
||||
public static short getScreenOrientation() {
|
||||
return GeckoScreenOrientationListener.getInstance().getScreenOrientation();
|
||||
}
|
||||
|
||||
public static void enableScreenOrientationNotifications() {
|
||||
GeckoScreenOrientationListener.getInstance().enableNotifications();
|
||||
}
|
||||
|
||||
public static void disableScreenOrientationNotifications() {
|
||||
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ public class GeckoEvent {
|
||||
public static final int VISITED = 21;
|
||||
public static final int NETWORK_CHANGED = 22;
|
||||
public static final int PROXIMITY_EVENT = 23;
|
||||
public static final int SCREENORIENTATION_CHANGED = 24;
|
||||
|
||||
public static final int IME_COMPOSITION_END = 0;
|
||||
public static final int IME_COMPOSITION_BEGIN = 1;
|
||||
@ -127,8 +126,6 @@ public class GeckoEvent {
|
||||
public double mBandwidth;
|
||||
public boolean mCanBeMetered;
|
||||
|
||||
public short mScreenOrientation;
|
||||
|
||||
public int mNativeWindow;
|
||||
|
||||
public GeckoEvent() {
|
||||
@ -337,9 +334,4 @@ public class GeckoEvent {
|
||||
mBandwidth = bandwidth;
|
||||
mCanBeMetered = canBeMetered;
|
||||
}
|
||||
|
||||
public GeckoEvent(short aScreenOrientation) {
|
||||
mType = SCREENORIENTATION_CHANGED;
|
||||
mScreenOrientation = aScreenOrientation;
|
||||
}
|
||||
}
|
||||
|
@ -1,122 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.Surface;
|
||||
|
||||
public class GeckoScreenOrientationListener
|
||||
{
|
||||
static class OrientationEventListenerImpl extends OrientationEventListener {
|
||||
public OrientationEventListenerImpl(Context c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOrientationChanged(int aOrientation) {
|
||||
GeckoScreenOrientationListener.getInstance().updateScreenOrientation();
|
||||
}
|
||||
}
|
||||
|
||||
static private GeckoScreenOrientationListener sInstance = null;
|
||||
|
||||
// Make sure that any change in dom/base/ScreenOrientation.h happens here too.
|
||||
static public final short eScreenOrientation_PortraitPrimary = 1;
|
||||
static public final short eScreenOrientation_PortraitSecondary = 2;
|
||||
static public final short eScreenOrientation_LandscapePrimary = 4;
|
||||
static public final short eScreenOrientation_LandscapeSecondary = 8;
|
||||
|
||||
private short mOrientation;
|
||||
private OrientationEventListenerImpl mListener = null;
|
||||
|
||||
// Whether the listener should be listening to changes.
|
||||
private boolean mShouldBeListening = false;
|
||||
// Whether the listener should notify Gecko that a change happened.
|
||||
private boolean mShouldNotify = false;
|
||||
|
||||
private GeckoScreenOrientationListener() {
|
||||
mListener = new OrientationEventListenerImpl(GeckoApp.mAppContext);
|
||||
}
|
||||
|
||||
public static GeckoScreenOrientationListener getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new GeckoScreenOrientationListener();
|
||||
}
|
||||
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mShouldBeListening = true;
|
||||
updateScreenOrientation();
|
||||
|
||||
if (mShouldNotify) {
|
||||
startListening();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mShouldBeListening = false;
|
||||
|
||||
if (mShouldNotify) {
|
||||
stopListening();
|
||||
}
|
||||
}
|
||||
|
||||
public void enableNotifications() {
|
||||
updateScreenOrientation();
|
||||
mShouldNotify = true;
|
||||
|
||||
if (mShouldBeListening) {
|
||||
startListening();
|
||||
}
|
||||
}
|
||||
|
||||
public void disableNotifications() {
|
||||
mShouldNotify = false;
|
||||
|
||||
if (mShouldBeListening) {
|
||||
stopListening();
|
||||
}
|
||||
}
|
||||
|
||||
private void startListening() {
|
||||
mListener.enable();
|
||||
}
|
||||
|
||||
private void stopListening() {
|
||||
mListener.disable();
|
||||
}
|
||||
|
||||
// NOTE: this is public so OrientationEventListenerImpl can access it.
|
||||
// Unfortunately, Java doesn't know about friendship.
|
||||
public void updateScreenOrientation() {
|
||||
int rotation = GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getRotation();
|
||||
short previousOrientation = mOrientation;
|
||||
|
||||
if (rotation == Surface.ROTATION_0) {
|
||||
mOrientation = eScreenOrientation_PortraitPrimary;
|
||||
} else if (rotation == Surface.ROTATION_180) {
|
||||
mOrientation = eScreenOrientation_PortraitSecondary;
|
||||
} else if (rotation == Surface.ROTATION_270) {
|
||||
mOrientation = eScreenOrientation_LandscapeSecondary;
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
mOrientation = eScreenOrientation_LandscapePrimary;
|
||||
} else {
|
||||
Log.e("GeckoScreenOrientationListener", "Unexpected value received! (" + rotation + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mShouldNotify && mOrientation != previousOrientation) {
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(mOrientation));
|
||||
}
|
||||
}
|
||||
|
||||
public short getScreenOrientation() {
|
||||
return mOrientation;
|
||||
}
|
||||
}
|
@ -57,7 +57,6 @@ JAVAFILES = \
|
||||
GeckoBatteryManager.java \
|
||||
VideoPlayer.java \
|
||||
GeckoNetworkManager.java \
|
||||
GeckoScreenOrientationListener.java \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_WEBSMS_BACKEND
|
||||
|
47
hal/Hal.cpp
47
hal/Hal.cpp
@ -25,7 +25,6 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "WindowIdentifier.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
|
||||
using namespace mozilla::services;
|
||||
|
||||
@ -265,24 +264,6 @@ protected:
|
||||
|
||||
static NetworkObserversManager sNetworkObservers;
|
||||
|
||||
class ScreenOrientationObserversManager : public ObserversManager<dom::ScreenOrientationWrapper>
|
||||
{
|
||||
protected:
|
||||
void EnableNotifications() {
|
||||
PROXY_IF_SANDBOXED(EnableScreenOrientationNotifications());
|
||||
}
|
||||
|
||||
void DisableNotifications() {
|
||||
PROXY_IF_SANDBOXED(DisableScreenOrientationNotifications());
|
||||
}
|
||||
|
||||
void GetCurrentInformationInternal(dom::ScreenOrientationWrapper* aInfo) {
|
||||
PROXY_IF_SANDBOXED(GetCurrentScreenOrientation(&(aInfo->orientation)));
|
||||
}
|
||||
};
|
||||
|
||||
static ScreenOrientationObserversManager sScreenOrientationObservers;
|
||||
|
||||
void
|
||||
RegisterBatteryObserver(BatteryObserver* aObserver)
|
||||
{
|
||||
@ -445,33 +426,5 @@ void PowerOff()
|
||||
PROXY_IF_SANDBOXED(PowerOff());
|
||||
}
|
||||
|
||||
void
|
||||
RegisterScreenOrientationObserver(hal::ScreenOrientationObserver* aObserver)
|
||||
{
|
||||
AssertMainThread();
|
||||
sScreenOrientationObservers.AddObserver(aObserver);
|
||||
}
|
||||
|
||||
void
|
||||
UnregisterScreenOrientationObserver(hal::ScreenOrientationObserver* aObserver)
|
||||
{
|
||||
AssertMainThread();
|
||||
sScreenOrientationObservers.RemoveObserver(aObserver);
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
|
||||
{
|
||||
AssertMainThread();
|
||||
*aScreenOrientation = sScreenOrientationObservers.GetCurrentInformation().orientation;
|
||||
}
|
||||
|
||||
void
|
||||
NotifyScreenOrientationChange(const dom::ScreenOrientation& aScreenOrientation)
|
||||
{
|
||||
sScreenOrientationObservers.CacheInformation(dom::ScreenOrientationWrapper(aScreenOrientation));
|
||||
sScreenOrientationObservers.BroadcastCachedInformation();
|
||||
}
|
||||
|
||||
} // namespace hal
|
||||
} // namespace mozilla
|
||||
|
33
hal/Hal.h
33
hal/Hal.h
@ -21,7 +21,6 @@
|
||||
#include "mozilla/dom/battery/Types.h"
|
||||
#include "mozilla/dom/network/Types.h"
|
||||
#include "mozilla/hal_sandbox/PHal.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
|
||||
/*
|
||||
* Hal.h contains the public Hal API.
|
||||
@ -42,17 +41,8 @@ class nsIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
template <class T>
|
||||
class Observer;
|
||||
|
||||
namespace dom {
|
||||
class ScreenOrientationWrapper;
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
|
||||
typedef Observer<dom::ScreenOrientationWrapper> ScreenOrientationObserver;
|
||||
|
||||
class WindowIdentifier;
|
||||
|
||||
extern PRLogModuleInfo *sHalLog;
|
||||
@ -243,29 +233,6 @@ void Reboot();
|
||||
*/
|
||||
void PowerOff();
|
||||
|
||||
/**
|
||||
* Inform the backend there is a new screen orientation observer.
|
||||
* @param aScreenOrientationObserver The observer that should be added.
|
||||
*/
|
||||
void RegisterScreenOrientationObserver(hal::ScreenOrientationObserver* aScreenOrientationObserver);
|
||||
|
||||
/**
|
||||
* Inform the backend a screen orientation observer unregistered.
|
||||
* @param aScreenOrientationObserver The observer that should be removed.
|
||||
*/
|
||||
void UnregisterScreenOrientationObserver(hal::ScreenOrientationObserver* aScreenOrientationObserver);
|
||||
|
||||
/**
|
||||
* Returns the current screen orientation.
|
||||
*/
|
||||
void GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation);
|
||||
|
||||
/**
|
||||
* Notify of a change in the screen orientation.
|
||||
* @param aScreenOrientation The new screen orientation.
|
||||
*/
|
||||
void NotifyScreenOrientationChange(const dom::ScreenOrientation& aScreenOrientation);
|
||||
|
||||
} // namespace MOZ_HAL_NAMESPACE
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -77,16 +77,6 @@ void EnableNetworkNotifications();
|
||||
*/
|
||||
void DisableNetworkNotifications();
|
||||
|
||||
/**
|
||||
* Enables screen orientation notifications from the backend.
|
||||
*/
|
||||
void EnableScreenOrientationNotifications();
|
||||
|
||||
/**
|
||||
* Disables screen orientation notifications from the backend.
|
||||
*/
|
||||
void DisableScreenOrientationNotifications();
|
||||
|
||||
} // namespace MOZ_HAL_NAMESPACE
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -108,11 +108,6 @@ ifneq (gonk,$(MOZ_WIDGET_TOOLKIT)) #{
|
||||
CPPSRCS += FallbackLights.cpp
|
||||
endif #}
|
||||
|
||||
# Screen Orientation backend
|
||||
ifneq (android,$(MOZ_WIDGET_TOOLKIT))
|
||||
CPPSRCS += ScreenOrientationFallback.cpp
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/ipc/chromium/chromium-config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "WindowIdentifier.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "mozilla/dom/network/Constants.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
|
||||
using mozilla::hal::WindowIdentifier;
|
||||
|
||||
@ -182,41 +181,6 @@ void
|
||||
PowerOff()
|
||||
{}
|
||||
|
||||
void
|
||||
EnableScreenOrientationNotifications()
|
||||
{
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->EnableScreenOrientationNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
DisableScreenOrientationNotifications()
|
||||
{
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
bridge->DisableScreenOrientationNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
|
||||
{
|
||||
AndroidBridge* bridge = AndroidBridge::Bridge();
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
|
||||
dom::ScreenOrientationWrapper orientationWrapper;
|
||||
bridge->GetScreenOrientation(orientationWrapper);
|
||||
*aScreenOrientation = orientationWrapper.orientation;
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
||||
|
||||
|
@ -1,45 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Hal.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
#include "nsIScreenManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
EnableScreenOrientationNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DisableScreenOrientationNotifications()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentScreenOrientation(dom::ScreenOrientation* aScreenOrientation)
|
||||
{
|
||||
nsresult result;
|
||||
nsCOMPtr<nsIScreenManager> screenMgr =
|
||||
do_GetService("@mozilla.org/gfx/screenmanager;1", &result);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_ERROR("Can't find nsIScreenManager!");
|
||||
return;
|
||||
}
|
||||
|
||||
PRInt32 screenLeft, screenTop, screenWidth, screenHeight;
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
|
||||
screenMgr->GetPrimaryScreen(getter_AddRefs(screen));
|
||||
screen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight);
|
||||
|
||||
*aScreenOrientation = screenWidth >= screenHeight
|
||||
? dom::eScreenOrientation_LandscapePrimary
|
||||
: dom::eScreenOrientation_PortraitPrimary;
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
} // mozilla
|
@ -42,14 +42,12 @@ include protocol PBrowser;
|
||||
include "nspr/prtime.h";
|
||||
include "mozilla/HalSensor.h";
|
||||
include "mozilla/HalTypes.h";
|
||||
include "mozilla/dom/ScreenOrientation.h";
|
||||
|
||||
using PRTime;
|
||||
using mozilla::hal::FlashMode;
|
||||
using mozilla::hal::LightType;
|
||||
using mozilla::hal::LightMode;
|
||||
using mozilla::hal::SensorType;
|
||||
using mozilla::dom::ScreenOrientation;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -74,7 +72,9 @@ namespace hal {
|
||||
PRTime timestamp;
|
||||
float[] values;
|
||||
};
|
||||
}
|
||||
|
||||
namespace hal {
|
||||
struct NetworkInformation {
|
||||
double bandwidth;
|
||||
bool canBeMetered;
|
||||
@ -89,7 +89,6 @@ sync protocol PHal {
|
||||
child:
|
||||
NotifyBatteryChange(BatteryInformation aBatteryInfo);
|
||||
NotifyNetworkChange(NetworkInformation aNetworkInfo);
|
||||
NotifyScreenOrientationChange(ScreenOrientation aScreenOrientation);
|
||||
|
||||
parent:
|
||||
Vibrate(uint32[] pattern, uint64[] id, PBrowser browser);
|
||||
@ -119,11 +118,6 @@ parent:
|
||||
Reboot();
|
||||
PowerOff();
|
||||
|
||||
EnableScreenOrientationNotifications();
|
||||
DisableScreenOrientationNotifications();
|
||||
sync GetCurrentScreenOrientation()
|
||||
returns (ScreenOrientation aScreenOrientation);
|
||||
|
||||
child:
|
||||
NotifySensorChange(SensorData aSensorData);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/battery/Types.h"
|
||||
#include "mozilla/dom/network/Types.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
#include "mozilla/Observer.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "WindowIdentifier.h"
|
||||
@ -98,24 +97,6 @@ GetCurrentNetworkInformation(NetworkInformation* aNetworkInfo)
|
||||
Hal()->SendGetCurrentNetworkInformation(aNetworkInfo);
|
||||
}
|
||||
|
||||
void
|
||||
EnableScreenOrientationNotifications()
|
||||
{
|
||||
Hal()->SendEnableScreenOrientationNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
DisableScreenOrientationNotifications()
|
||||
{
|
||||
Hal()->SendDisableScreenOrientationNotifications();
|
||||
}
|
||||
|
||||
void
|
||||
GetCurrentScreenOrientation(ScreenOrientation* aScreenOrientation)
|
||||
{
|
||||
Hal()->SendGetCurrentScreenOrientation(aScreenOrientation);
|
||||
}
|
||||
|
||||
bool
|
||||
GetScreenEnabled()
|
||||
{
|
||||
@ -186,7 +167,6 @@ class HalParent : public PHalParent
|
||||
, public BatteryObserver
|
||||
, public NetworkObserver
|
||||
, public ISensorObserver
|
||||
, public ScreenOrientationObserver
|
||||
{
|
||||
public:
|
||||
NS_OVERRIDE virtual bool
|
||||
@ -272,28 +252,6 @@ public:
|
||||
unused << SendNotifyNetworkChange(aNetworkInfo);
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvEnableScreenOrientationNotifications() {
|
||||
hal::RegisterScreenOrientationObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvDisableScreenOrientationNotifications() {
|
||||
hal::UnregisterScreenOrientationObserver(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvGetCurrentScreenOrientation(ScreenOrientation* aScreenOrientation) {
|
||||
hal::GetCurrentScreenOrientation(aScreenOrientation);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Notify(const ScreenOrientationWrapper& aScreenOrientation) {
|
||||
unused << SendNotifyScreenOrientationChange(aScreenOrientation.orientation);
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvGetScreenEnabled(bool *enabled)
|
||||
{
|
||||
@ -383,12 +341,6 @@ public:
|
||||
hal::NotifyNetworkChange(aNetworkInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvNotifyScreenOrientationChange(const ScreenOrientation& aScreenOrientation) {
|
||||
hal::NotifyScreenOrientationChange(aScreenOrientation);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
bool
|
||||
|
@ -4005,9 +4005,9 @@ nsLayoutUtils::GetRectDifferenceStrips(const nsRect& aR1, const nsRect& aR2,
|
||||
}
|
||||
|
||||
nsDeviceContext*
|
||||
nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow)
|
||||
nsLayoutUtils::GetDeviceContextForScreenInfo(nsIDocShell* aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
|
||||
nsCOMPtr<nsIDocShell> docShell = aDocShell;
|
||||
while (docShell) {
|
||||
// Now make sure our size is up to date. That will mean that the device
|
||||
// context does the right thing on multi-monitor systems when we return it to
|
||||
|
@ -1330,11 +1330,11 @@ public:
|
||||
|
||||
/**
|
||||
* Get a device context that can be used to get up-to-date device
|
||||
* dimensions for the given window. For some reason, this is more
|
||||
* dimensions for the given docshell. For some reason, this is more
|
||||
* complicated than it ought to be in multi-monitor situations.
|
||||
*/
|
||||
static nsDeviceContext*
|
||||
GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow);
|
||||
GetDeviceContextForScreenInfo(nsIDocShell* aDocShell);
|
||||
|
||||
/**
|
||||
* Some frames with 'position: fixed' (nsStylePosition::mDisplay ==
|
||||
|
@ -2060,7 +2060,6 @@ abstract public class GeckoApp
|
||||
|
||||
unregisterReceiver(mConnectivityReceiver);
|
||||
GeckoNetworkManager.getInstance().stop();
|
||||
GeckoScreenOrientationListener.getInstance().stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2086,7 +2085,6 @@ abstract public class GeckoApp
|
||||
|
||||
registerReceiver(mConnectivityReceiver, mConnectivityFilter);
|
||||
GeckoNetworkManager.getInstance().start();
|
||||
GeckoScreenOrientationListener.getInstance().start();
|
||||
|
||||
if (mOwnActivityDepth > 0)
|
||||
mOwnActivityDepth--;
|
||||
@ -2171,7 +2169,6 @@ abstract public class GeckoApp
|
||||
}
|
||||
|
||||
GeckoNetworkManager.getInstance().stop();
|
||||
GeckoScreenOrientationListener.getInstance().stop();
|
||||
|
||||
super.onDestroy();
|
||||
|
||||
|
@ -1976,16 +1976,4 @@ public class GeckoAppShell
|
||||
public static byte[] decodeBase64(String s, int flags) {
|
||||
return decodeBase64(s.getBytes(), flags);
|
||||
}
|
||||
|
||||
public static short getScreenOrientation() {
|
||||
return GeckoScreenOrientationListener.getInstance().getScreenOrientation();
|
||||
}
|
||||
|
||||
public static void enableScreenOrientationNotifications() {
|
||||
GeckoScreenOrientationListener.getInstance().enableNotifications();
|
||||
}
|
||||
|
||||
public static void disableScreenOrientationNotifications() {
|
||||
GeckoScreenOrientationListener.getInstance().disableNotifications();
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,6 @@ public class GeckoEvent {
|
||||
public static final int VISITED = 21;
|
||||
public static final int NETWORK_CHANGED = 22;
|
||||
public static final int PROXIMITY_EVENT = 23;
|
||||
public static final int SCREENORIENTATION_CHANGED = 24;
|
||||
|
||||
public static final int IME_COMPOSITION_END = 0;
|
||||
public static final int IME_COMPOSITION_BEGIN = 1;
|
||||
@ -134,8 +133,6 @@ public class GeckoEvent {
|
||||
public double mBandwidth;
|
||||
public boolean mCanBeMetered;
|
||||
|
||||
public short mScreenOrientation;
|
||||
|
||||
public int mNativeWindow;
|
||||
|
||||
public GeckoEvent() {
|
||||
@ -362,9 +359,4 @@ public class GeckoEvent {
|
||||
mBandwidth = bandwidth;
|
||||
mCanBeMetered = canBeMetered;
|
||||
}
|
||||
|
||||
public GeckoEvent(short aScreenOrientation) {
|
||||
mType = SCREENORIENTATION_CHANGED;
|
||||
mScreenOrientation = aScreenOrientation;
|
||||
}
|
||||
}
|
||||
|
@ -1,122 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.Surface;
|
||||
|
||||
public class GeckoScreenOrientationListener
|
||||
{
|
||||
static class OrientationEventListenerImpl extends OrientationEventListener {
|
||||
public OrientationEventListenerImpl(Context c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOrientationChanged(int aOrientation) {
|
||||
GeckoScreenOrientationListener.getInstance().updateScreenOrientation();
|
||||
}
|
||||
}
|
||||
|
||||
static private GeckoScreenOrientationListener sInstance = null;
|
||||
|
||||
// Make sure that any change in dom/base/ScreenOrientation.h happens here too.
|
||||
static public final short eScreenOrientation_PortraitPrimary = 1;
|
||||
static public final short eScreenOrientation_PortraitSecondary = 2;
|
||||
static public final short eScreenOrientation_LandscapePrimary = 4;
|
||||
static public final short eScreenOrientation_LandscapeSecondary = 8;
|
||||
|
||||
private short mOrientation;
|
||||
private OrientationEventListenerImpl mListener = null;
|
||||
|
||||
// Whether the listener should be listening to changes.
|
||||
private boolean mShouldBeListening = false;
|
||||
// Whether the listener should notify Gecko that a change happened.
|
||||
private boolean mShouldNotify = false;
|
||||
|
||||
private GeckoScreenOrientationListener() {
|
||||
mListener = new OrientationEventListenerImpl(GeckoApp.mAppContext);
|
||||
}
|
||||
|
||||
public static GeckoScreenOrientationListener getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new GeckoScreenOrientationListener();
|
||||
}
|
||||
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mShouldBeListening = true;
|
||||
updateScreenOrientation();
|
||||
|
||||
if (mShouldNotify) {
|
||||
startListening();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mShouldBeListening = false;
|
||||
|
||||
if (mShouldNotify) {
|
||||
stopListening();
|
||||
}
|
||||
}
|
||||
|
||||
public void enableNotifications() {
|
||||
updateScreenOrientation();
|
||||
mShouldNotify = true;
|
||||
|
||||
if (mShouldBeListening) {
|
||||
startListening();
|
||||
}
|
||||
}
|
||||
|
||||
public void disableNotifications() {
|
||||
mShouldNotify = false;
|
||||
|
||||
if (mShouldBeListening) {
|
||||
stopListening();
|
||||
}
|
||||
}
|
||||
|
||||
private void startListening() {
|
||||
mListener.enable();
|
||||
}
|
||||
|
||||
private void stopListening() {
|
||||
mListener.disable();
|
||||
}
|
||||
|
||||
// NOTE: this is public so OrientationEventListenerImpl can access it.
|
||||
// Unfortunately, Java doesn't know about friendship.
|
||||
public void updateScreenOrientation() {
|
||||
int rotation = GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getRotation();
|
||||
short previousOrientation = mOrientation;
|
||||
|
||||
if (rotation == Surface.ROTATION_0) {
|
||||
mOrientation = eScreenOrientation_PortraitPrimary;
|
||||
} else if (rotation == Surface.ROTATION_180) {
|
||||
mOrientation = eScreenOrientation_PortraitSecondary;
|
||||
} else if (rotation == Surface.ROTATION_270) {
|
||||
mOrientation = eScreenOrientation_LandscapeSecondary;
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
mOrientation = eScreenOrientation_LandscapePrimary;
|
||||
} else {
|
||||
Log.e("GeckoScreenOrientationListener", "Unexpected value received! (" + rotation + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mShouldNotify && mOrientation != previousOrientation) {
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(mOrientation));
|
||||
}
|
||||
}
|
||||
|
||||
public short getScreenOrientation() {
|
||||
return mOrientation;
|
||||
}
|
||||
}
|
@ -136,7 +136,6 @@ FENNEC_JAVA_FILES = \
|
||||
ui/SimpleScaleGestureDetector.java \
|
||||
ui/SubdocumentScrollHelper.java \
|
||||
GeckoNetworkManager.java \
|
||||
GeckoScreenOrientationListener.java \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_WEBSMS_BACKEND
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIThreadManager.h"
|
||||
#include "mozilla/dom/sms/PSms.h"
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ALOG_BRIDGE(args...) ALOG(args)
|
||||
@ -174,10 +173,6 @@ AndroidBridge::Init(JNIEnv *jEnv,
|
||||
jEnableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableNetworkNotifications", "()V");
|
||||
jDisableNetworkNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableNetworkNotifications", "()V");
|
||||
|
||||
jGetScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getScreenOrientation", "()S");
|
||||
jEnableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableScreenOrientationNotifications", "()V");
|
||||
jDisableScreenOrientationNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableScreenOrientationNotifications", "()V");
|
||||
|
||||
jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext"));
|
||||
jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10"));
|
||||
jEGLSurfaceImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl"));
|
||||
@ -1964,24 +1959,3 @@ AndroidBridge::HideSurface(jobject surface)
|
||||
env->CallStaticVoidMethod(cls, method, surface);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation)
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::GetScreenOrientation");
|
||||
aOrientation.orientation = static_cast<dom::ScreenOrientation>(mJNIEnv->CallStaticShortMethod(mGeckoAppShellClass, jGetScreenOrientation));
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::EnableScreenOrientationNotifications()
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::EnableScreenOrientationNotifications");
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jEnableScreenOrientationNotifications);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::DisableScreenOrientationNotifications()
|
||||
{
|
||||
ALOG_BRIDGE("AndroidBridge::DisableScreenOrientationNotifications");
|
||||
mJNIEnv->CallStaticVoidMethod(mGeckoAppShellClass, jDisableScreenOrientationNotifications);
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ class NetworkInformation;
|
||||
} // namespace hal
|
||||
|
||||
namespace dom {
|
||||
class ScreenOrientationWrapper;
|
||||
namespace sms {
|
||||
struct SmsFilterData;
|
||||
} // namespace sms
|
||||
@ -389,14 +388,6 @@ public:
|
||||
void ShowSurface(jobject surface, const gfxRect& aRect, bool aInverted, bool aBlend);
|
||||
void HideSurface(jobject surface);
|
||||
|
||||
// This method doesn't take a ScreenOrientation because it's an enum and
|
||||
// that would require including the header which requires include IPC
|
||||
// headers which requires including basictypes.h which requires a lot of
|
||||
// changes...
|
||||
void GetScreenOrientation(dom::ScreenOrientationWrapper& aOrientation);
|
||||
void EnableScreenOrientationNotifications();
|
||||
void DisableScreenOrientationNotifications();
|
||||
|
||||
protected:
|
||||
static AndroidBridge *sBridge;
|
||||
|
||||
@ -496,10 +487,6 @@ protected:
|
||||
jmethodID jEnableNetworkNotifications;
|
||||
jmethodID jDisableNetworkNotifications;
|
||||
|
||||
jmethodID jGetScreenOrientation;
|
||||
jmethodID jEnableScreenOrientationNotifications;
|
||||
jmethodID jDisableScreenOrientationNotifications;
|
||||
|
||||
// stuff we need for CallEglCreateWindowSurface
|
||||
jclass jEGLSurfaceImplClass;
|
||||
jclass jEGLContextImplClass;
|
||||
|
@ -76,7 +76,6 @@ jfieldID AndroidGeckoEvent::jLocationField = 0;
|
||||
jfieldID AndroidGeckoEvent::jAddressField = 0;
|
||||
jfieldID AndroidGeckoEvent::jBandwidthField = 0;
|
||||
jfieldID AndroidGeckoEvent::jCanBeMeteredField = 0;
|
||||
jfieldID AndroidGeckoEvent::jScreenOrientationField = 0;
|
||||
|
||||
jclass AndroidPoint::jPointClass = 0;
|
||||
jfieldID AndroidPoint::jXField = 0;
|
||||
@ -190,7 +189,6 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv)
|
||||
jAddressField = getField("mAddress", "Landroid/location/Address;");
|
||||
jBandwidthField = getField("mBandwidth", "D");
|
||||
jCanBeMeteredField = getField("mCanBeMetered", "Z");
|
||||
jScreenOrientationField = getField("mScreenOrientation", "S");
|
||||
}
|
||||
|
||||
void
|
||||
@ -549,11 +547,6 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj)
|
||||
break;
|
||||
}
|
||||
|
||||
case SCREENORIENTATION_CHANGED: {
|
||||
mScreenOrientation = jenv->GetShortField(jobj, jScreenOrientationField);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -462,7 +462,6 @@ public:
|
||||
nsGeoPositionAddress* GeoAddress() { return mGeoAddress; }
|
||||
double Bandwidth() { return mBandwidth; }
|
||||
bool CanBeMetered() { return mCanBeMetered; }
|
||||
short ScreenOrientation() { return mScreenOrientation; }
|
||||
|
||||
protected:
|
||||
int mAction;
|
||||
@ -488,7 +487,6 @@ protected:
|
||||
nsRefPtr<nsGeoPositionAddress> mGeoAddress;
|
||||
double mBandwidth;
|
||||
bool mCanBeMetered;
|
||||
short mScreenOrientation;
|
||||
|
||||
void ReadIntArray(nsTArray<int> &aVals,
|
||||
JNIEnv *jenv,
|
||||
@ -544,8 +542,6 @@ protected:
|
||||
static jfieldID jBandwidthField;
|
||||
static jfieldID jCanBeMeteredField;
|
||||
|
||||
static jfieldID jScreenOrientationField;
|
||||
|
||||
public:
|
||||
enum {
|
||||
NATIVE_POKE = 0,
|
||||
@ -571,7 +567,6 @@ public:
|
||||
VISITED = 21,
|
||||
NETWORK_CHANGED = 22,
|
||||
PROXIMITY_EVENT = 23,
|
||||
SCREENORIENTATION_CHANGED = 24,
|
||||
dummy_java_enum_list_end
|
||||
};
|
||||
|
||||
|
@ -61,8 +61,6 @@
|
||||
#include <pthread.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "mozilla/dom/ScreenOrientation.h"
|
||||
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
#include "nsAndroidHistory.h"
|
||||
#endif
|
||||
@ -485,11 +483,6 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
|
||||
break;
|
||||
}
|
||||
|
||||
case AndroidGeckoEvent::SCREENORIENTATION_CHANGED: {
|
||||
hal::NotifyScreenOrientationChange(static_cast<dom::ScreenOrientation>(curEvent->ScreenOrientation()));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
nsWindow::OnGlobalAndroidEvent(curEvent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user