Bug 938035 - The definition of device orientation in firefox is not same as w3c spec. r=dougt
authorViral Wang <vwang@mozilla.com>
Tue, 26 Nov 2013 13:58:15 -0500
changeset 157622 3d937509b0fe6900e718d13354b1af167dac30b6
parent 157621 1f5ec27b648d2a556ad639799a219068c866b40a
child 157623 912b38085d2db23612e15c537fe71a3aabd0968f
push id25717
push userkwierso@gmail.com
push dateWed, 27 Nov 2013 01:34:26 +0000
treeherdermozilla-central@a6a046acc881 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs938035
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 938035 - The definition of device orientation in firefox is not same as w3c spec. r=dougt
hal/gonk/GonkSensor.cpp
widget/android/nsAppShell.cpp
--- a/hal/gonk/GonkSensor.cpp
+++ b/hal/gonk/GonkSensor.cpp
@@ -181,16 +181,24 @@ PollSensors()
       break;
     }
 
     for (int i = 0; i < n; ++i) {
       // FIXME: bug 802004, add proper support for the magnetic field sensor.
       if (buffer[i].type == SENSOR_TYPE_MAGNETIC_FIELD)
         continue;
 
+      // Bug 938035, transfer HAL data for orientation sensor to meet w3c spec
+      // ex: HAL report alpha=90 means East but alpha=90 means West in w3c spec
+      if (buffer[i].type == SENSOR_TYPE_ORIENTATION) {
+        buffer[i].orientation.azimuth = 360 - buffer[i].orientation.azimuth;
+        buffer[i].orientation.pitch = -buffer[i].orientation.pitch;
+        buffer[i].orientation.roll = -buffer[i].orientation.roll;
+      }
+
       if (HardwareSensorToHalSensor(buffer[i].type) == SENSOR_UNKNOWN) {
         // Emulator is broken and gives us events without types set
         int index;
         for (index = 0; index < size; index++) {
           if (sensors[index].handle == buffer[i].sensor) {
             break;
           }
         }
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -307,17 +307,24 @@ nsAppShell::ProcessNextNativeEvent(bool 
         break;
 
     case AndroidGeckoEvent::SENSOR_EVENT:
       {
         InfallibleTArray<float> values;
         mozilla::hal::SensorType type = (mozilla::hal::SensorType) curEvent->Flags();
 
         switch (type) {
+          // Bug 938035, transfer HAL data for orientation sensor to meet w3c
+          // spec, ex: HAL report alpha=90 means East but alpha=90 means West
+          // in w3c spec
           case hal::SENSOR_ORIENTATION:
+            values.AppendElement(360 -curEvent->X());
+            values.AppendElement(-curEvent->Y()); 
+            values.AppendElement(-curEvent->Z());
+            break;
           case hal::SENSOR_LINEAR_ACCELERATION:
           case hal::SENSOR_ACCELERATION:
           case hal::SENSOR_GYROSCOPE:
           case hal::SENSOR_PROXIMITY:
             values.AppendElement(curEvent->X());
             values.AppendElement(curEvent->Y()); 
             values.AppendElement(curEvent->Z());
             break;