Bug 743198 part 6 - Add unprefixed fullscreen events. r=smaug
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 17 Feb 2016 08:47:11 +0800
changeset 284442 5210ded8bd67
parent 284441 dd1694d9700f
child 284443 a72b6cfcb2e1
push id30003
push usercbook@mozilla.com
push date2016-02-17 10:52 +0000
treeherdermozilla-central@15621f98b53b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs743198
milestone47.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 743198 part 6 - Add unprefixed fullscreen events. r=smaug
dom/base/ScreenOrientation.cpp
dom/base/nsDocument.cpp
dom/base/nsGkAtomList.h
dom/events/EventListenerManager.cpp
dom/events/EventNameList.h
dom/webidl/EventHandler.webidl
widget/EventMessageList.h
--- a/dom/base/ScreenOrientation.cpp
+++ b/dom/base/ScreenOrientation.cpp
@@ -359,17 +359,17 @@ ScreenOrientation::LockDeviceOrientation
 
   if (NS_WARN_IF(!hal::LockScreenOrientation(aOrientation))) {
     return false;
   }
 
   // We are fullscreen and lock has been accepted.
   if (aIsFullScreen && !mFullScreenListener) {
     mFullScreenListener = new FullScreenEventListener();
-    aRv = target->AddSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),
+    aRv = target->AddSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
                                          mFullScreenListener, /* useCapture = */ true);
     if (NS_WARN_IF(aRv.Failed())) {
       return false;
     }
   }
 
   return true;
 }
@@ -387,17 +387,17 @@ ScreenOrientation::UnlockDeviceOrientati
 
   if (!mFullScreenListener) {
     return;
   }
 
   // Remove event listener in case of fullscreen lock.
   nsCOMPtr<EventTarget> target = do_QueryInterface(GetOwner()->GetDoc());
   if (target) {
-    nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),
+    nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
                                                     mFullScreenListener, /* useCapture */ true);
     NS_WARN_IF(NS_FAILED(rv));
   }
 
   mFullScreenListener = nullptr;
 }
 
 OrientationType
@@ -624,17 +624,17 @@ NS_IMPL_ISUPPORTS(ScreenOrientation::Ful
 
 NS_IMETHODIMP
 ScreenOrientation::FullScreenEventListener::HandleEvent(nsIDOMEvent* aEvent)
 {
 #ifdef DEBUG
   nsAutoString eventType;
   aEvent->GetType(eventType);
 
-  MOZ_ASSERT(eventType.EqualsLiteral("mozfullscreenchange"));
+  MOZ_ASSERT(eventType.EqualsLiteral("fullscreenchange"));
 #endif
 
   nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
   MOZ_ASSERT(target);
 
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
   MOZ_ASSERT(doc);
 
@@ -642,14 +642,14 @@ ScreenOrientation::FullScreenEventListen
   // fullscreen is disabled because we could get one when fullscreen
   // got enabled if the lock call is done at the same moment.
   if (doc->MozFullScreen()) {
     return NS_OK;
   }
 
   hal::UnlockScreenOrientation();
 
-  nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("mozfullscreenchange"),
+  nsresult rv = target->RemoveSystemEventListener(NS_LITERAL_STRING("fullscreenchange"),
                                                   this, true);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -9207,17 +9207,17 @@ DispatchCustomEventWithFlush(nsINode* aT
       RefreshDriver()->ScheduleEventDispatch(aTarget, event);
   }
 }
 
 static void
 DispatchFullScreenChange(nsIDocument* aTarget)
 {
   DispatchCustomEventWithFlush(
-    aTarget, NS_LITERAL_STRING("mozfullscreenchange"),
+    aTarget, NS_LITERAL_STRING("fullscreenchange"),
     /* Bubbles */ true, /* OnlyChrome */ false);
 }
 
 static void ClearPendingFullscreenRequests(nsIDocument* aDoc);
 
 void
 nsDocument::OnPageHide(bool aPersisted,
                        EventTarget* aDispatchStartTarget)
@@ -11168,27 +11168,27 @@ nsIDocument::ExitFullscreenInDocTree(nsI
     // not being a fullscreen doc also means the widget should have
     // exited fullscreen state. It means even if we do not return here,
     // we would actually do nothing below except crashing ourselves via
     // dispatching the "MozDOMFullscreen:Exited" event to an nonexistent
     // document.
     return;
   }
 
-  // Stores a list of documents to which we must dispatch "mozfullscreenchange".
+  // Stores a list of documents to which we must dispatch "fullscreenchange".
   // We're required by the spec to dispatch the events in leaf-to-root
   // order when exiting fullscreen, but we traverse the doctree in a
   // root-to-leaf order, so we save references to the documents we must
   // dispatch to so that we dispatch in the specified order.
   nsCOMArray<nsIDocument> changed;
 
   // Walk the tree of fullscreen documents, and reset their fullscreen state.
   ResetFullScreen(root, static_cast<void*>(&changed));
 
-  // Dispatch "mozfullscreenchange" events. Note this loop is in reverse
+  // Dispatch "fullscreenchange" events. Note this loop is in reverse
   // order so that the events for the leaf document arrives before the root
   // document, as required by the spec.
   for (uint32_t i = 0; i < changed.Length(); ++i) {
     DispatchFullScreenChange(changed[changed.Length() - i - 1]);
   }
 
   NS_ASSERTION(!root->IsFullScreenDoc(),
     "Fullscreen root should no longer be a fullscreen doc...");
@@ -11354,17 +11354,17 @@ nsDocument::AsyncRequestFullScreen(Uniqu
   NS_DispatchToCurrentThread(event);
 }
 
 void
 nsIDocument::DispatchFullscreenError(const char* aMessage)
 {
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this,
-                             NS_LITERAL_STRING("mozfullscreenerror"),
+                             NS_LITERAL_STRING("fullscreenerror"),
                              true,
                              false);
   asyncDispatcher->PostDOMEvent();
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("DOM"), this,
                                   nsContentUtils::eDOM_PROPERTIES,
                                   aMessage);
 }
@@ -11890,17 +11890,17 @@ nsDocument::ApplyFullscreen(const Fullsc
   if (!FullscreenElementReadyCheck(elem, aRequest.mIsCallerChrome)) {
     return false;
   }
 
   // Stash a reference to any existing fullscreen doc, we'll use this later
   // to detect if the origin which is fullscreen has changed.
   nsCOMPtr<nsIDocument> previousFullscreenDoc = GetFullscreenLeaf(this);
 
-  // Stores a list of documents which we must dispatch "mozfullscreenchange"
+  // Stores a list of documents which we must dispatch "fullscreenchange"
   // too. We're required by the spec to dispatch the events in root-to-leaf
   // order, but we traverse the doctree in a leaf-to-root order, so we save
   // references to the documents we must dispatch to so that we get the order
   // as specified.
   AutoTArray<nsIDocument*, 8> changed;
 
   // Remember the root document, so that if a full-screen document is hidden
   // we can reset full-screen state in the remaining visible full-screen documents.
@@ -11977,17 +11977,17 @@ nsDocument::ApplyFullscreen(const Fullsc
   // shouldn't rely on this event itself.
   if (aRequest.mShouldNotifyNewOrigin &&
       !nsContentUtils::HaveEqualPrincipals(previousFullscreenDoc, this)) {
     DispatchCustomEventWithFlush(
       this, NS_LITERAL_STRING("MozDOMFullscreen:NewOrigin"),
       /* Bubbles */ true, /* ChromeOnly */ true);
   }
 
-  // Dispatch "mozfullscreenchange" events. Note this loop is in reverse
+  // Dispatch "fullscreenchange" events. Note this loop is in reverse
   // order so that the events for the root document arrives before the leaf
   // document, as required by the spec.
   for (uint32_t i = 0; i < changed.Length(); ++i) {
     DispatchFullScreenChange(changed[changed.Length() - i - 1]);
   }
   return true;
 }
 
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -407,16 +407,18 @@ GK_ATOM(formatNumber, "format-number")
 GK_ATOM(formenctype, "formenctype")
 GK_ATOM(formmethod, "formmethod")
 GK_ATOM(formnovalidate, "formnovalidate")
 GK_ATOM(formtarget, "formtarget")
 GK_ATOM(frame, "frame")
 GK_ATOM(frameborder, "frameborder")
 GK_ATOM(frameset, "frameset")
 GK_ATOM(from, "from")
+GK_ATOM(fullscreenchange, "fullscreenchange")
+GK_ATOM(fullscreenerror, "fullscreenerror")
 GK_ATOM(functionAvailable, "function-available")
 GK_ATOM(generateId, "generate-id")
 GK_ATOM(getter, "getter")
 GK_ATOM(glyphchar, "glyphchar")
 GK_ATOM(glyphid, "glyphid")
 GK_ATOM(grid, "grid")
 GK_ATOM(grippy, "grippy")
 GK_ATOM(group, "group")
@@ -780,16 +782,18 @@ GK_ATOM(onemergencycbmodechange, "onemer
 GK_ATOM(onerror, "onerror")
 GK_ATOM(onevicted, "onevicted")
 GK_ATOM(onfacesdetected, "onfacesdetected")
 GK_ATOM(onfailed, "onfailed")
 GK_ATOM(onfetch, "onfetch")
 GK_ATOM(onfinish, "onfinish")
 GK_ATOM(onfocus, "onfocus")
 GK_ATOM(onfrequencychange, "onfrequencychange")
+GK_ATOM(onfullscreenchange, "onfullscreenchange")
+GK_ATOM(onfullscreenerror, "onfullscreenerror")
 GK_ATOM(onspeakerforcedchange, "onspeakerforcedchange")
 GK_ATOM(onget, "onget")
 GK_ATOM(ongroupchange, "ongroupchange")
 GK_ATOM(onhashchange, "onhashchange")
 GK_ATOM(onheadphoneschange, "onheadphoneschange")
 GK_ATOM(onheld, "onheld")
 GK_ATOM(onhfpstatuschanged, "onhfpstatuschanged")
 GK_ATOM(onholding, "onholding")
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -1122,17 +1122,24 @@ EventListenerManager::GetLegacyEventMess
     if (aEventMessage == eAnimationEnd) {
       return eWebkitAnimationEnd;
     }
     if (aEventMessage == eAnimationIteration) {
       return eWebkitAnimationIteration;
     }
   }
 
-  return aEventMessage;
+  switch (aEventMessage) {
+    case eFullscreenChange:
+      return eMozFullscreenChange;
+    case eFullscreenError:
+      return eMozFullscreenError;
+    default:
+      return aEventMessage;
+  }
 }
 
 nsIDocShell*
 EventListenerManager::GetDocShellForTarget()
 {
   nsCOMPtr<nsINode> node(do_QueryInterface(mTarget));
   nsIDocument* doc = nullptr;
   nsIDocShell* docShell = nullptr;
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -213,16 +213,24 @@ EVENT(durationchange,
 EVENT(emptied,
       eEmptied,
       EventNameType_HTML,
       eBasicEventClass)
 EVENT(ended,
       eEnded,
       EventNameType_HTML,
       eBasicEventClass)
+EVENT(fullscreenchange,
+      eFullscreenChange,
+      EventNameType_HTML,
+      eBasicEventClass)
+EVENT(fullscreenerror,
+      eFullscreenError,
+      EventNameType_HTML,
+      eBasicEventClass)
 EVENT(input,
       eEditorInput,
       EventNameType_HTMLXUL,
       eEditorInputEventClass)
 EVENT(invalid,
       eFormInvalid,
       EventNameType_HTMLXUL,
       eBasicEventClass)
@@ -290,21 +298,21 @@ EVENT(mouseover,
       eMouseOver,
       EventNameType_All,
       eMouseEventClass)
 EVENT(mouseup,
       eMouseUp,
       EventNameType_All,
       eMouseEventClass)
 EVENT(mozfullscreenchange,
-      eFullscreenChange,
+      eMozFullscreenChange,
       EventNameType_HTML,
       eBasicEventClass)
 EVENT(mozfullscreenerror,
-      eFullscreenError,
+      eMozFullscreenError,
       EventNameType_HTML,
       eBasicEventClass)
 EVENT(mozpointerlockchange,
       ePointerLockChange,
       EventNameType_HTML,
       eBasicEventClass)
 EVENT(mozpointerlockerror,
       ePointerLockError,
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -109,19 +109,23 @@ interface GlobalEventHandlers {
            attribute EventHandler onpointerenter;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onpointerleave;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler ongotpointercapture;
            [Pref="dom.w3c_pointer_events.enabled"]
            attribute EventHandler onlostpointercapture;
 
-           // Mozilla-specific handlers
+           // Fullscreen events handlers
+           attribute EventHandler onfullscreenchange;
+           attribute EventHandler onfullscreenerror;
            attribute EventHandler onmozfullscreenchange;
            attribute EventHandler onmozfullscreenerror;
+
+           // Mozilla-specific handlers
            attribute EventHandler onmozpointerlockchange;
            attribute EventHandler onmozpointerlockerror;
 };
 
 [NoInterfaceObject]
 interface WindowEventHandlers {
            attribute EventHandler onafterprint;
            attribute EventHandler onbeforeprint;
--- a/widget/EventMessageList.h
+++ b/widget/EventMessageList.h
@@ -354,16 +354,18 @@ NS_EVENT_MESSAGE(eDeviceLight)
 NS_EVENT_MESSAGE(eOrientationChange)
 #endif
 
 NS_EVENT_MESSAGE(eShow)
 
 // Fullscreen DOM API
 NS_EVENT_MESSAGE(eFullscreenChange)
 NS_EVENT_MESSAGE(eFullscreenError)
+NS_EVENT_MESSAGE(eMozFullscreenChange)
+NS_EVENT_MESSAGE(eMozFullscreenError)
 
 NS_EVENT_MESSAGE(eTouchStart)
 NS_EVENT_MESSAGE(eTouchMove)
 NS_EVENT_MESSAGE(eTouchEnd)
 NS_EVENT_MESSAGE(eTouchCancel)
 
 // Pointerlock DOM API
 NS_EVENT_MESSAGE(ePointerLockChange)