Bug 787534 - Remove Portrait and Landscape special ScreenOrientation values. r=jlebar

This commit is contained in:
Mounir Lamouri
2012-09-19 17:28:16 +01:00
parent cae14080ff
commit c91a040038
8 changed files with 44 additions and 42 deletions

View File

@@ -16,12 +16,10 @@ namespace dom {
typedef uint32_t ScreenOrientation; typedef uint32_t ScreenOrientation;
static const ScreenOrientation eScreenOrientation_None = 0; static const ScreenOrientation eScreenOrientation_None = 0;
static const ScreenOrientation eScreenOrientation_PortraitPrimary = 1; // 00000001 static const ScreenOrientation eScreenOrientation_PortraitPrimary = PR_BIT(0);
static const ScreenOrientation eScreenOrientation_PortraitSecondary = 2; // 00000010 static const ScreenOrientation eScreenOrientation_PortraitSecondary = PR_BIT(1);
static const ScreenOrientation eScreenOrientation_Portrait = 3; // 00000011 static const ScreenOrientation eScreenOrientation_LandscapePrimary = PR_BIT(2);
static const ScreenOrientation eScreenOrientation_LandscapePrimary = 4; // 00000100 static const ScreenOrientation eScreenOrientation_LandscapeSecondary = PR_BIT(3);
static const ScreenOrientation eScreenOrientation_LandscapeSecondary = 8; // 00001000
static const ScreenOrientation eScreenOrientation_Landscape = 12; // 00001100
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

View File

@@ -276,9 +276,10 @@ nsScreen::Notify(const hal::ScreenConfiguration& aConfiguration)
ScreenOrientation previousOrientation = mOrientation; ScreenOrientation previousOrientation = mOrientation;
mOrientation = aConfiguration.orientation(); mOrientation = aConfiguration.orientation();
NS_ASSERTION(mOrientation != eScreenOrientation_None && NS_ASSERTION(mOrientation == eScreenOrientation_PortraitPrimary ||
mOrientation != eScreenOrientation_Portrait && mOrientation == eScreenOrientation_PortraitSecondary ||
mOrientation != eScreenOrientation_Landscape, mOrientation == eScreenOrientation_LandscapePrimary ||
mOrientation == eScreenOrientation_LandscapeSecondary,
"Invalid orientation value passed to notify method!"); "Invalid orientation value passed to notify method!");
if (mOrientation != previousOrientation) { if (mOrientation != previousOrientation) {
@@ -306,11 +307,6 @@ NS_IMETHODIMP
nsScreen::GetMozOrientation(nsAString& aOrientation) nsScreen::GetMozOrientation(nsAString& aOrientation)
{ {
switch (mOrientation) { switch (mOrientation) {
case eScreenOrientation_None:
case eScreenOrientation_Portrait:
case eScreenOrientation_Landscape:
NS_ASSERTION(false, "Shouldn't be used when getting value!");
return NS_ERROR_FAILURE;
case eScreenOrientation_PortraitPrimary: case eScreenOrientation_PortraitPrimary:
aOrientation.AssignLiteral("portrait-primary"); aOrientation.AssignLiteral("portrait-primary");
break; break;
@@ -323,6 +319,10 @@ nsScreen::GetMozOrientation(nsAString& aOrientation)
case eScreenOrientation_LandscapeSecondary: case eScreenOrientation_LandscapeSecondary:
aOrientation.AssignLiteral("landscape-secondary"); aOrientation.AssignLiteral("landscape-secondary");
break; break;
case eScreenOrientation_None:
default:
MOZ_ASSERT(false);
return NS_ERROR_FAILURE;
} }
return NS_OK; return NS_OK;
@@ -406,13 +406,15 @@ nsScreen::MozLockOrientation(const jsval& aOrientation, JSContext* aCx, bool* aR
nsString& item = orientations[i]; nsString& item = orientations[i];
if (item.EqualsLiteral("portrait")) { if (item.EqualsLiteral("portrait")) {
orientation |= eScreenOrientation_Portrait; orientation |= eScreenOrientation_PortraitPrimary |
eScreenOrientation_PortraitSecondary;
} else if (item.EqualsLiteral("portrait-primary")) { } else if (item.EqualsLiteral("portrait-primary")) {
orientation |= eScreenOrientation_PortraitPrimary; orientation |= eScreenOrientation_PortraitPrimary;
} else if (item.EqualsLiteral("portrait-secondary")) { } else if (item.EqualsLiteral("portrait-secondary")) {
orientation |= eScreenOrientation_PortraitSecondary; orientation |= eScreenOrientation_PortraitSecondary;
} else if (item.EqualsLiteral("landscape")) { } else if (item.EqualsLiteral("landscape")) {
orientation |= eScreenOrientation_Landscape; orientation |= eScreenOrientation_LandscapePrimary |
eScreenOrientation_LandscapeSecondary;
} else if (item.EqualsLiteral("landscape-primary")) { } else if (item.EqualsLiteral("landscape-primary")) {
orientation |= eScreenOrientation_LandscapePrimary; orientation |= eScreenOrientation_LandscapePrimary;
} else if (item.EqualsLiteral("landscape-secondary")) { } else if (item.EqualsLiteral("landscape-secondary")) {

View File

@@ -120,10 +120,12 @@ void anp_window_requestFullScreenOrientation(NPP instance, ANPScreenOrientation
newOrientation = eScreenOrientation_PortraitPrimary; newOrientation = eScreenOrientation_PortraitPrimary;
break; break;
case kLandscape_ANPScreenOrientation: case kLandscape_ANPScreenOrientation:
newOrientation = eScreenOrientation_Landscape; newOrientation = eScreenOrientation_LandscapePrimary |
eScreenOrientation_LandscapeSecondary;
break; break;
case kPortrait_ANPScreenOrientation: case kPortrait_ANPScreenOrientation:
newOrientation = eScreenOrientation_Portrait; newOrientation = eScreenOrientation_PortraitPrimary |
eScreenOrientation_PortraitSecondary;
break; break;
default: default:
newOrientation = eScreenOrientation_None; newOrientation = eScreenOrientation_None;

View File

@@ -29,12 +29,10 @@ public class GeckoScreenOrientationListener
// Make sure that any change in dom/base/ScreenOrientation.h happens here too. // Make sure that any change in dom/base/ScreenOrientation.h happens here too.
static public final short eScreenOrientation_None = 0; static public final short eScreenOrientation_None = 0;
static public final short eScreenOrientation_PortraitPrimary = 1; static public final short eScreenOrientation_PortraitPrimary = 1; // PR_BIT(0)
static public final short eScreenOrientation_PortraitSecondary = 2; static public final short eScreenOrientation_PortraitSecondary = 2; // PR_BIT(1)
static public final short eScreenOrientation_Portrait = 3; static public final short eScreenOrientation_LandscapePrimary = 4; // PR_BIT(2)
static public final short eScreenOrientation_LandscapePrimary = 4; static public final short eScreenOrientation_LandscapeSecondary = 8; // PR_BIT(3)
static public final short eScreenOrientation_LandscapeSecondary = 8;
static public final short eScreenOrientation_Landscape = 12;
private short mOrientation; private short mOrientation;
private OrientationEventListenerImpl mListener = null; private OrientationEventListenerImpl mListener = null;
@@ -136,7 +134,7 @@ public class GeckoScreenOrientationListener
case eScreenOrientation_PortraitSecondary: case eScreenOrientation_PortraitSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break; break;
case eScreenOrientation_Portrait: case eScreenOrientation_PortraitPrimary | eScreenOrientation_PortraitSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
break; break;
case eScreenOrientation_LandscapePrimary: case eScreenOrientation_LandscapePrimary:
@@ -145,7 +143,7 @@ public class GeckoScreenOrientationListener
case eScreenOrientation_LandscapeSecondary: case eScreenOrientation_LandscapeSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break; break;
case eScreenOrientation_Landscape: case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
break; break;
default: default:

View File

@@ -189,10 +189,10 @@ LockScreenOrientation(const ScreenOrientation& aOrientation)
// The Android backend only supports these orientations. // The Android backend only supports these orientations.
case eScreenOrientation_PortraitPrimary: case eScreenOrientation_PortraitPrimary:
case eScreenOrientation_PortraitSecondary: case eScreenOrientation_PortraitSecondary:
case eScreenOrientation_Portrait: case eScreenOrientation_PortraitPrimary | eScreenOrientation_PortraitSecondary:
case eScreenOrientation_LandscapePrimary: case eScreenOrientation_LandscapePrimary:
case eScreenOrientation_LandscapeSecondary: case eScreenOrientation_LandscapeSecondary:
case eScreenOrientation_Landscape: case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
bridge->LockScreenOrientation(aOrientation); bridge->LockScreenOrientation(aOrientation);
return true; return true;
default: default:

View File

@@ -31,12 +31,10 @@ public class GeckoScreenOrientationListener {
// Make sure that any change in dom/base/ScreenOrientation.h happens here too. // Make sure that any change in dom/base/ScreenOrientation.h happens here too.
static public final short eScreenOrientation_None = 0; static public final short eScreenOrientation_None = 0;
static public final short eScreenOrientation_PortraitPrimary = 1; static public final short eScreenOrientation_PortraitPrimary = 1; // PR_BIT(0)
static public final short eScreenOrientation_PortraitSecondary = 2; static public final short eScreenOrientation_PortraitSecondary = 2; // PR_BIT(1)
static public final short eScreenOrientation_Portrait = 3; static public final short eScreenOrientation_LandscapePrimary = 4; // PR_BIT(2)
static public final short eScreenOrientation_LandscapePrimary = 4; static public final short eScreenOrientation_LandscapeSecondary = 8; // PR_BIT(3)
static public final short eScreenOrientation_LandscapeSecondary = 8;
static public final short eScreenOrientation_Landscape = 12;
static private final short DEFAULT_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; static private final short DEFAULT_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -178,7 +176,7 @@ public class GeckoScreenOrientationListener {
case eScreenOrientation_PortraitSecondary: case eScreenOrientation_PortraitSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break; break;
case eScreenOrientation_Portrait: case eScreenOrientation_PortraitPrimary | eScreenOrientation_PortraitSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
break; break;
case eScreenOrientation_LandscapePrimary: case eScreenOrientation_LandscapePrimary:
@@ -187,7 +185,7 @@ public class GeckoScreenOrientationListener {
case eScreenOrientation_LandscapeSecondary: case eScreenOrientation_LandscapeSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break; break;
case eScreenOrientation_Landscape: case eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary:
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE; orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
break; break;
default: default:

View File

@@ -37,10 +37,10 @@ struct OrientationMapping {
static OrientationMapping sOrientationMappings[] = { static OrientationMapping sOrientationMappings[] = {
{nsIScreen::ROTATION_0_DEG, eScreenOrientation_PortraitPrimary}, {nsIScreen::ROTATION_0_DEG, eScreenOrientation_PortraitPrimary},
{nsIScreen::ROTATION_180_DEG, eScreenOrientation_PortraitSecondary}, {nsIScreen::ROTATION_180_DEG, eScreenOrientation_PortraitSecondary},
{nsIScreen::ROTATION_0_DEG, eScreenOrientation_Portrait}, {nsIScreen::ROTATION_0_DEG, eScreenOrientation_PortraitPrimary | eScreenOrientation_PortraitSecondary},
{nsIScreen::ROTATION_90_DEG, eScreenOrientation_LandscapePrimary}, {nsIScreen::ROTATION_90_DEG, eScreenOrientation_LandscapePrimary},
{nsIScreen::ROTATION_270_DEG, eScreenOrientation_LandscapeSecondary}, {nsIScreen::ROTATION_270_DEG, eScreenOrientation_LandscapeSecondary},
{nsIScreen::ROTATION_90_DEG, eScreenOrientation_Landscape} {nsIScreen::ROTATION_90_DEG, eScreenOrientation_LandscapePrimary | eScreenOrientation_LandscapeSecondary}
}; };
const static int sDefaultLandscape = 3; const static int sDefaultLandscape = 3;
@@ -290,8 +290,10 @@ OrientationObserver::LockScreenOrientation(ScreenOrientation aOrientation)
// Enable/disable the observer depending on 1. multiple orientations // Enable/disable the observer depending on 1. multiple orientations
// allowed, and 2. observer enabled. // allowed, and 2. observer enabled.
if (aOrientation == eScreenOrientation_Landscape || if (aOrientation == (eScreenOrientation_LandscapePrimary |
aOrientation == eScreenOrientation_Portrait) { eScreenOrientation_LandscapeSecondary) ||
aOrientation == (eScreenOrientation_PortraitPrimary |
eScreenOrientation_PortraitSecondary)) {
if (!mAutoOrientationEnabled) { if (!mAutoOrientationEnabled) {
EnableAutoOrientation(); EnableAutoOrientation();
} }

View File

@@ -62,8 +62,10 @@ private:
// 200 ms, the latency which is barely perceptible by human. // 200 ms, the latency which is barely perceptible by human.
static const PRTime sMinUpdateInterval = 200 * PR_USEC_PER_MSEC; static const PRTime sMinUpdateInterval = 200 * PR_USEC_PER_MSEC;
static const uint32_t sDefaultOrientations = static const uint32_t sDefaultOrientations =
mozilla::dom::eScreenOrientation_Portrait | mozilla::dom::eScreenOrientation_PortraitPrimary |
mozilla::dom::eScreenOrientation_Landscape; mozilla::dom::eScreenOrientation_PortraitSecondary |
mozilla::dom::eScreenOrientation_LandscapePrimary |
mozilla::dom::eScreenOrientation_LandscapeSecondary;
}; };
#endif #endif