Bug 1268749 part 5 - Avoid dispatching unprefixed fullscreen events to content if unprefixed API is disabled. r=smaug a=lizzard
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 09 May 2016 09:43:57 +1000
changeset 332771 3023e4f667a3c3ed207edbbb5f2afc0f2aea63b1
parent 332770 a12048ebd87a5b03002de61f8a332933e76a3e50
child 332772 450bf777896c63ae590821487f918b7e90dab075
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lizzard
bugs1268749
milestone48.0a2
Bug 1268749 part 5 - Avoid dispatching unprefixed fullscreen events to content if unprefixed API is disabled. r=smaug a=lizzard MozReview-Commit-ID: BLL7xr0EJu8
dom/events/EventListenerManager.cpp
dom/events/EventListenerManager.h
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -279,16 +279,18 @@ EventListenerManager::AddEventListenerIn
   listener->mListener = aListenerHolder;
   listener->mEventMessage = aEventMessage;
   listener->mTypeString = aTypeString;
   listener->mTypeAtom = aTypeAtom;
   listener->mFlags = aFlags;
   listener->mListenerIsHandler = aHandler;
   listener->mHandlerIsString = false;
   listener->mAllEvents = aAllEvents;
+  listener->mIsChrome = mIsMainThreadELM &&
+    nsContentUtils::LegacyIsCallerChromeOrNativeCode();
 
   // Detect the type of event listener.
   nsCOMPtr<nsIXPConnectWrappedJS> wjs;
   if (aFlags.mListenerIsJSListener) {
     MOZ_ASSERT(!aListenerHolder.HasWebIDLCallback());
     listener->mListenerType = Listener::eJSEventListener;
   } else if (aListenerHolder.HasWebIDLCallback()) {
     listener->mListenerType = Listener::eWebIDLListener;
@@ -673,16 +675,25 @@ EventListenerManager::ListenerCanHandle(
     return true;
   }
   if (aEvent->mMessage == eUnidentifiedEvent) {
     if (mIsMainThreadELM) {
       return aListener->mTypeAtom == aEvent->mSpecifiedEventType;
     }
     return aListener->mTypeString.Equals(aEvent->mSpecifiedEventTypeString);
   }
+  if (!nsContentUtils::IsUnprefixedFullscreenApiEnabled() &&
+      aEvent->IsTrusted() && (aEventMessage == eFullscreenChange ||
+                              aEventMessage == eFullscreenError)) {
+    // If unprefixed Fullscreen API is not enabled, don't dispatch it
+    // to the content.
+    if (!aEvent->mFlags.mInSystemGroup && !aListener->mIsChrome) {
+      return false;
+    }
+  }
   MOZ_ASSERT(mIsMainThreadELM);
   return aListener->mEventMessage == aEventMessage;
 }
 
 void
 EventListenerManager::AddEventListenerByType(
                         const EventListenerHolder& aListenerHolder,
                         const nsAString& aType,
--- a/dom/events/EventListenerManager.h
+++ b/dom/events/EventListenerManager.h
@@ -190,16 +190,17 @@ public:
       eWebIDLListener,
       eListenerTypeCount
     };
     uint8_t mListenerType;
 
     bool mListenerIsHandler : 1;
     bool mHandlerIsString : 1;
     bool mAllEvents : 1;
+    bool mIsChrome : 1;
 
     EventListenerFlags mFlags;
 
     JSEventHandler* GetJSEventHandler() const
     {
       return (mListenerType == eJSEventListener) ?
         static_cast<JSEventHandler*>(mListener.GetXPCOMCallback()) :
         nullptr;