Bug 1223561 - Support putting <table> into fullscreen. r=dbaron
☠☠ backed out by 4044c905be7b ☠ ☠
authorXidorn Quan <me@upsuper.org>
Tue, 22 Nov 2016 16:31:56 +1100
changeset 323960 535f8682016bdc71be4d604bdf61c9247ca47feb
parent 323959 b4822cdc2dfeef9e03c58f6d138568b60dc130bb
child 323961 25b4cc6088ef59bcccf2499bf9c0e3e921164b2c
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdbaron
bugs1223561
milestone53.0a1
Bug 1223561 - Support putting <table> into fullscreen. r=dbaron MozReview-Commit-ID: 5ohJW9U65dr
dom/html/test/file_fullscreen-table.html
dom/html/test/mochitest.ini
dom/html/test/test_fullscreen-api.html
layout/generic/nsPlaceholderFrame.cpp
layout/style/res/ua.css
new file mode 100644
--- /dev/null
+++ b/dom/html/test/file_fullscreen-table.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="UTF-8">
+  <title>Test for Bug 1223561</title>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+  <script type="text/javascript" src="file_fullscreen-utils.js"></script>
+</head>
+<body>
+<table style="background-color: green"></table>
+<script>
+"use strict";
+
+function ok(condition, msg) {
+  opener.ok(condition, "[table] " + msg);
+}
+
+function is(a, b, msg) {
+  opener.is(a, b, "[table] " + msg);
+}
+
+function info(msg) {
+  opener.info("[table] " + msg);
+}
+
+const gTable = document.querySelector("table");
+
+function begin() {
+  info("The default background of window should be white");
+  addFullscreenChangeContinuation("enter", enteredFullscreen);
+  assertWindowPureColor(window, "white");
+  gTable.requestFullscreen();
+}
+
+function enteredFullscreen() {
+  info("The table with green background should be in fullscreen");
+  assertWindowPureColor(window, "green");
+  gTable.style = "background: transparent";
+  info("When the table becames transparent, the black backdrop should appear");
+  assertWindowPureColor(window, "black");
+  addFullscreenChangeContinuation("exit", exitedFullscreen);
+  document.exitFullscreen();
+}
+
+function exitedFullscreen() {
+  opener.nextTest();
+}
+</script>
+</body>
+</html>
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -48,38 +48,16 @@ support-files =
   file_bug209275_2.html
   file_bug209275_3.html
   file_bug297761.html
   file_bug417760.png
   file_bug893537.html
   file_bug1260704.png
   file_formSubmission_img.jpg
   file_formSubmission_text.txt
-  file_fullscreen-api.html
-  file_fullscreen-backdrop.html
-  file_fullscreen-denied-inner.html
-  file_fullscreen-denied.html
-  file_fullscreen-esc-exit-inner.html
-  file_fullscreen-esc-exit.html
-  file_fullscreen-hidden.html
-  file_fullscreen-lenient-setters.html
-  file_fullscreen-multiple-inner.html
-  file_fullscreen-multiple.html
-  file_fullscreen-navigation.html
-  file_fullscreen-nested.html
-  file_fullscreen-prefixed.html
-  file_fullscreen-plugins.html
-  file_fullscreen-rollback.html
-  file_fullscreen-scrollbar.html
-  file_fullscreen-selector.html
-  file_fullscreen-svg-element.html
-  file_fullscreen-top-layer.html
-  file_fullscreen-unprefix-disabled-inner.html
-  file_fullscreen-unprefix-disabled.html
-  file_fullscreen-utils.js
   file_iframe_sandbox_a_if1.html
   file_iframe_sandbox_a_if10.html
   file_iframe_sandbox_a_if11.html
   file_iframe_sandbox_a_if12.html
   file_iframe_sandbox_a_if13.html
   file_iframe_sandbox_a_if14.html
   file_iframe_sandbox_a_if15.html
   file_iframe_sandbox_a_if16.html
@@ -456,16 +434,40 @@ support-files =
 [test_formSubmission.html]
 skip-if = toolkit == 'android' #TIMED_OUT
 [test_formSubmission2.html]
 skip-if = toolkit == 'android'
 [test_formelements.html]
 [test_fullscreen-api.html]
 tags = fullscreen
 skip-if = toolkit == 'android'
+support-files =
+  file_fullscreen-api.html
+  file_fullscreen-backdrop.html
+  file_fullscreen-denied-inner.html
+  file_fullscreen-denied.html
+  file_fullscreen-esc-exit-inner.html
+  file_fullscreen-esc-exit.html
+  file_fullscreen-hidden.html
+  file_fullscreen-lenient-setters.html
+  file_fullscreen-multiple-inner.html
+  file_fullscreen-multiple.html
+  file_fullscreen-navigation.html
+  file_fullscreen-nested.html
+  file_fullscreen-prefixed.html
+  file_fullscreen-plugins.html
+  file_fullscreen-rollback.html
+  file_fullscreen-scrollbar.html
+  file_fullscreen-selector.html
+  file_fullscreen-svg-element.html
+  file_fullscreen-table.html
+  file_fullscreen-top-layer.html
+  file_fullscreen-unprefix-disabled-inner.html
+  file_fullscreen-unprefix-disabled.html
+  file_fullscreen-utils.js
 [test_fullscreen-api-race.html]
 tags = fullscreen
 skip-if = toolkit == 'android' # just copy the conditions from the test above
 [test_hidden.html]
 [test_html_attributes_reflection.html]
 [test_htmlcollection.html]
 [test_iframe_sandbox_general.html]
 tags = openwindow
--- a/dom/html/test/test_fullscreen-api.html
+++ b/dom/html/test/test_fullscreen-api.html
@@ -40,16 +40,17 @@ var gTestWindows = [
   "file_fullscreen-scrollbar.html",
   "file_fullscreen-selector.html",
   "file_fullscreen-top-layer.html",
   "file_fullscreen-backdrop.html",
   "file_fullscreen-nested.html",
   "file_fullscreen-prefixed.html",
   "file_fullscreen-unprefix-disabled.html",
   "file_fullscreen-lenient-setters.html",
+  "file_fullscreen-table.html",
 ];
 
 var testWindow = null;
 var gTestIndex = 0;
 
 function finish() {
   SimpleTest.finish();
 }
--- a/layout/generic/nsPlaceholderFrame.cpp
+++ b/layout/generic/nsPlaceholderFrame.cpp
@@ -201,20 +201,35 @@ nsPlaceholderFrame::GetParentStyleContex
     nsStyleContext* sc =
       PresContext()->FrameManager()->GetDisplayContentsStyleFor(parentContent);
     if (sc) {
       *aProviderFrame = nullptr;
       return sc;
     }
   }
 
+  nsIFrame* parentFrame = GetParent();
+  // Placeholder of backdrop frame is a child of the corresponding top
+  // layer frame, and its style context inherits from that frame. In
+  // case of table, the top layer frame is the table wrapper frame.
+  // However, it will be skipped in CorrectStyleParentFrame below, so
+  // we need to handle it specially here.
+  if ((GetStateBits() & PLACEHOLDER_FOR_TOPLAYER) &&
+      parentFrame->GetType() == nsGkAtoms::tableWrapperFrame) {
+    MOZ_ASSERT(mOutOfFlowFrame->GetType() == nsGkAtoms::backdropFrame,
+               "Only placeholder of backdrop frame can be put inside "
+               "a table wrapper frame");
+    return parentFrame->StyleContext();
+  }
+
   // Lie about our pseudo so we can step out of all anon boxes and
   // pseudo-elements.  The other option would be to reimplement the
   // {ib} split gunk here.
-  *aProviderFrame = CorrectStyleParentFrame(GetParent(), nsGkAtoms::placeholderFrame);
+  *aProviderFrame = CorrectStyleParentFrame(parentFrame,
+                                            nsGkAtoms::placeholderFrame);
   return *aProviderFrame ? (*aProviderFrame)->StyleContext() : nullptr;
 }
 
 
 #ifdef DEBUG
 static void
 PaintDebugPlaceholder(nsIFrame* aFrame, DrawTarget* aDrawTarget,
                       const nsRect& aDirtyRect, nsPoint aPt)
--- a/layout/style/res/ua.css
+++ b/layout/style/res/ua.css
@@ -17,17 +17,21 @@
 }
 
 *|*::-moz-inline-table {
   display: inline-table !important;
   box-sizing: border-box; /* XXX do we really want this? */
 }
 
 *|*::-moz-table-wrapper {
+  /* The inherited properties here need to be safe to have on both the
+   * table and the table wrapper, generally because code ignores them
+   * for the table. */
   display: inherit !important; /* table or inline-table */
+  -moz-top-layer: inherit !important;
   margin: inherit ! important;
   padding: 0 ! important;
   border: none ! important;
   float: inherit;
   clear: inherit;
   position: inherit;
   top: inherit;
   right: inherit;