Bug 939319 - Provide a drag-and-drop observer to allow event filtering. r=Enn
authorGeorg Koppen <gk@torproject.org>
Fri, 24 Jan 2014 08:29:47 -0500
changeset 181073 96f5df57e9b797c35e2cc1fc27ab67e506022123
parent 181072 3cf6fcb75118778672743cb68ca2dee6890d20d4
child 181074 a53cbf955a909247cbac06e35d63a298e9f70941
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs939319
milestone29.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 939319 - Provide a drag-and-drop observer to allow event filtering. r=Enn
dom/events/nsEventStateManager.cpp
--- a/dom/events/nsEventStateManager.cpp
+++ b/dom/events/nsEventStateManager.cpp
@@ -2159,16 +2159,25 @@ nsEventStateManager::GenerateDragGesture
       WidgetDragEvent* event = &startEvent;
       if (status != nsEventStatus_eConsumeNoDefault) {
         status = nsEventStatus_eIgnore;
         nsEventDispatcher::Dispatch(targetContent, aPresContext, &gestureEvent, nullptr,
                                     &status);
         event = &gestureEvent;
       }
 
+      nsCOMPtr<nsIObserverService> observerService =
+        mozilla::services::GetObserverService();
+      // Emit observer event to allow addons to modify the DataTransfer object.
+      if (observerService) {
+        observerService->NotifyObservers(dataTransfer,
+                                         "on-datatransfer-available",
+                                         nullptr);
+      }
+
       // now that the dataTransfer has been updated in the dragstart and
       // draggesture events, make it read only so that the data doesn't
       // change during the drag.
       dataTransfer->SetReadOnly();
 
       if (status != nsEventStatus_eConsumeNoDefault) {
         bool dragStarted = DoDefaultDragStart(aPresContext, event, dataTransfer,
                                               targetContent, selection);