Bug 743198 part 1 - Drop [Throws] of document.mozFullScreenElement. draft
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 04 Jan 2016 12:12:29 +1100
changeset 331128 4bf01545e9d8b6878046ddb8c038f65e2a9128d9
parent 331127 5c92e06561efe89a8f4a057cdab0bf9c7c6c35ff
child 331129 01131bb2e3b72f274cc4ac17f012199c24957c36
push id10905
push userxquan@mozilla.com
push dateTue, 16 Feb 2016 01:34:33 +0000
bugs743198
milestone47.0a1
Bug 743198 part 1 - Drop [Throws] of document.mozFullScreenElement. This method actually never throws. IsFullScreenDoc() simply checks whether GetFullScreenElement() returns nullptr, which means if that method returns true, the "!el" check would never fail. MozReview-Commit-ID: GTyPTqk894V
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/base/nsIDocument.h
dom/webidl/Document.webidl
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -11950,41 +11950,23 @@ nsDocument::ApplyFullscreen(const Fullsc
     DispatchFullScreenChange(changed[changed.Length() - i - 1]);
   }
   return true;
 }
 
 NS_IMETHODIMP
 nsDocument::GetMozFullScreenElement(nsIDOMElement **aFullScreenElement)
 {
-  ErrorResult rv;
-  Element* el = GetMozFullScreenElement(rv);
-  if (rv.Failed()) {
-    return rv.StealNSResult();
-  }
+  Element* el = GetMozFullScreenElement();
   nsCOMPtr<nsIDOMElement> retval = do_QueryInterface(el);
   retval.forget(aFullScreenElement);
   return NS_OK;
 }
 
 Element*
-nsDocument::GetMozFullScreenElement(ErrorResult& rv)
-{
-  if (IsFullScreenDoc()) {
-    // Must have a full-screen element while in full-screen mode.
-    Element* el = GetFullScreenElement();
-    if (!el) {
-      rv.Throw(NS_ERROR_UNEXPECTED);
-    }
-    return el;
-  }
-  return nullptr;
-}
-
-Element*
 nsDocument::GetFullScreenElement()
 {
   Element* element = FullScreenStackTop();
   NS_ASSERTION(!element ||
                element->IsFullScreenAncestor(),
     "Fullscreen element should have fullscreen styles applied");
   return element;
 }
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -1257,17 +1257,17 @@ public:
   // element, if there is one.
   void FullScreenStackPop();
 
   // Returns the top element from the full-screen stack.
   Element* FullScreenStackTop();
 
   // DOM-exposed fullscreen API
   virtual bool MozFullScreenEnabled() override;
-  virtual Element* GetMozFullScreenElement(mozilla::ErrorResult& rv) override;
+  Element* GetMozFullScreenElement() override { return GetFullScreenElement(); }
 
   void RequestPointerLock(Element* aElement) override;
   bool ShouldLockPointer(Element* aElement, Element* aCurrentLock,
                          bool aNoFocusCheck = false);
   bool SetPointerLock(Element* aElement, int aCursorStyle);
   static void UnlockPointer(nsIDocument* aDoc = nullptr);
 
   void SetCurrentOrientation(mozilla::dom::OrientationType aType,
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2499,17 +2499,17 @@ public:
   }
   Element* GetCurrentScript();
   void ReleaseCapture() const;
   virtual void MozSetImageElement(const nsAString& aImageElementId,
                                   Element* aElement) = 0;
   nsIURI* GetDocumentURIObject() const;
   // Not const because all the full-screen goop is not const
   virtual bool MozFullScreenEnabled() = 0;
-  virtual Element* GetMozFullScreenElement(mozilla::ErrorResult& rv) = 0;
+  virtual Element* GetMozFullScreenElement() = 0;
   bool MozFullScreen()
   {
     return IsFullScreenDoc();
   }
   void MozCancelFullScreen();
   Element* GetMozPointerLockElement();
   void MozExitPointerLock()
   {
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -220,17 +220,16 @@ partial interface Document {
 
 };
 
 // http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
 partial interface Document {
   // Note: Per spec the 'S' in these two is lowercase, but the "Moz"
   // versions hve it uppercase.
   readonly attribute boolean mozFullScreenEnabled;
-  [Throws]
   readonly attribute Element? mozFullScreenElement;
 
   //(Renamed?)void exitFullscreen();
 
   // Gecko-specific fullscreen bits
   readonly attribute boolean mozFullScreen;
   void mozCancelFullScreen();
 };