Bug 545812 - Implement iframe.mozallowfullscreen. r=jst
authorChris Pearce <chris@pearce.org.nz>
Mon, 05 Sep 2011 08:40:17 +1200
changeset 77846 26247cdde2bc41fc6189543bcb557ff00465e84d
parent 77845 be0876c4aa2bc9ff1e307e25111d214ebbc1a63b
child 77847 4a40fbf67f12309aca5d95392246305c95fac229
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs545812
milestone9.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 545812 - Implement iframe.mozallowfullscreen. r=jst
content/base/src/nsGkAtomList.h
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsHTMLIFrameElement.cpp
dom/interfaces/html/nsIDOMHTMLIFrameElement.idl
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -58,16 +58,17 @@
 #endif 
 
 //---------------------------------------------------------------------------
 // Generic atoms
 //---------------------------------------------------------------------------
 
 GK_ATOM(_empty, "")
 GK_ATOM(moz, "_moz")
+GK_ATOM(mozallowfullscreen, "mozallowfullscreen")
 GK_ATOM(moztype, "_moz-type")
 GK_ATOM(mozdirty, "_moz_dirty")
 GK_ATOM(mozdonotsend, "moz-do-not-send")
 GK_ATOM(mozeditorbogusnode, "_moz_editor_bogus_node")
 GK_ATOM(mozgeneratedcontentbefore, "_moz_generated_content_before")
 GK_ATOM(mozgeneratedcontentafter, "_moz_generated_content_after")
 GK_ATOM(mozgeneratedcontentimage, "_moz_generated_content_image")
 GK_ATOM(_moz_original_size, "_moz_original_size")
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -3380,16 +3380,31 @@ nsGenericHTMLElement::Focus()
 }
 
 nsresult nsGenericHTMLElement::MozRequestFullScreen()
 {
   if (!nsContentUtils::IsFullScreenApiEnabled()) {
     return NS_OK;
   }
 
+  // Ensure that all ancestor <iframe> elements have the mozallowfullscreen
+  // boolean attribute set.
+  nsINode* node = static_cast<nsINode*>(this);
+  do {
+    nsIContent* content = static_cast<nsIContent*>(node);
+    if (content->IsHTML(nsGkAtoms::iframe) &&
+        !content->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen)) {
+      // The node requesting fullscreen, or one of its crossdoc ancestors,
+      // is an iframe which doesn't have the "mozalllowfullscreen" attribute.
+      // This request is not authorized by the parent document.
+      return NS_OK;
+    }
+    node = nsContentUtils::GetCrossDocParentNode(node);
+  } while (node);
+
   nsIDocument* doc = GetOwnerDoc();
   NS_ENSURE_STATE(doc);
   doc->RequestFullScreen(this);
 #ifdef DEBUG
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(doc->GetWindow());
   NS_ENSURE_STATE(window);
   PRBool fullscreen;
   window->GetFullScreen(&fullscreen);
--- a/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -126,16 +126,17 @@ NS_IMPL_STRING_ATTR(nsHTMLIFrameElement,
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Height, height)
 NS_IMPL_URI_ATTR(nsHTMLIFrameElement, LongDesc, longdesc)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginWidth, marginwidth)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Name, name)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Scrolling, scrolling)
 NS_IMPL_URI_ATTR(nsHTMLIFrameElement, Src, src)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Width, width)
+NS_IMPL_BOOL_ATTR(nsHTMLIFrameElement, MozAllowFullScreen, mozallowfullscreen)
 
 NS_IMETHODIMP
 nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
 {
   return nsGenericHTMLFrameElement::GetContentDocument(aContentDocument);
 }
 
 NS_IMETHODIMP
--- a/dom/interfaces/html/nsIDOMHTMLIFrameElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLIFrameElement.idl
@@ -45,24 +45,29 @@
  *
  * This interface is trying to follow the DOM Level 2 HTML specification:
  * http://www.w3.org/TR/DOM-Level-2-HTML/
  *
  * with changes from the work-in-progress WHATWG HTML specification:
  * http://www.whatwg.org/specs/web-apps/current-work/
  */
 
-[scriptable, uuid(33dfbcdc-4edf-4e6a-acf4-c6b5bbb61caf)]
+[scriptable, uuid(31969911-36fb-42ee-9a00-018c3ff78cfb)]
 interface nsIDOMHTMLIFrameElement : nsIDOMHTMLElement
 {
            attribute DOMString        align;
            attribute DOMString        frameBorder;
            attribute DOMString        height;
            attribute DOMString        longDesc;
            attribute DOMString        marginHeight;
            attribute DOMString        marginWidth;
            attribute DOMString        name;
            attribute DOMString        scrolling;
            attribute DOMString        src;
            attribute DOMString        width;
   // Introduced in DOM Level 2:
   readonly attribute nsIDOMDocument   contentDocument;
+
+  // iframe elements require the mozAllowFullScreen attribute to be present
+  // if they're to allow content in the sub document to go into DOM full-screen
+  // mode. See https://wiki.mozilla.org/index.php?title=Gecko:FullScreenAPI
+           attribute boolean          mozAllowFullScreen;
 };