Bug 1257319 - Don't use broadcast event in AndroidContentController; r=rbarker
authorJim Chen <nchen@mozilla.com>
Wed, 23 Mar 2016 14:42:38 -0400
changeset 290114 2a961ff556b4542706cc5cd4e34cb0366e45ffad
parent 290113 87981beb2e893ccf2ab6229b0e3531fae15658dd
child 290115 29a11b0e6216044180f060cef75ee76af4e40fd8
push id30114
push usercbook@mozilla.com
push dateThu, 24 Mar 2016 15:15:54 +0000
treeherdermozilla-central@24c5fbde4488 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrbarker
bugs1257319
milestone48.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 1257319 - Don't use broadcast event in AndroidContentController; r=rbarker We should use observer service directly instead of broadcast event.
widget/android/AndroidContentController.cpp
--- a/widget/android/AndroidContentController.cpp
+++ b/widget/android/AndroidContentController.cpp
@@ -65,19 +65,27 @@ AndroidContentController::HandleSingleTa
             // We need to convert from the root document to the root content document,
             // by unapplying the resolution that's on the content document.
             const float resolution = shell->GetResolution();
             point.x /= resolution;
             point.y /= resolution;
         }
 
         CSSIntPoint rounded = RoundedToInt(point);
-        nsCString data = nsPrintfCString("{ \"x\": %d, \"y\": %d }", rounded.x, rounded.y);
-        nsAppShell::PostEvent(AndroidGeckoEvent::MakeBroadcastEvent(
-                NS_LITERAL_CSTRING("Gesture:SingleTap"), data));
+        nsAppShell::PostEvent([rounded] {
+            nsCOMPtr<nsIObserverService> obsServ =
+                mozilla::services::GetObserverService();
+            if (!obsServ) {
+                return;
+            }
+
+            nsPrintfCString data("{\"x\":%d,\"y\":%d}", rounded.x, rounded.y);
+            obsServ->NotifyObservers(nullptr, "Gesture:SingleTap",
+                                     NS_ConvertASCIItoUTF16(data).get());
+        });
     }
 
     ChromeProcessController::HandleSingleTap(aPoint, aModifiers, aGuid);
 }
 
 void
 AndroidContentController::PostDelayedTask(Task* aTask, int aDelayMs)
 {