Bug 1256084 - Don't force reflow on size mode change. r=heycam, a=ritu
authorBrendan Dahl <bdahl@mozilla.com>
Mon, 28 Mar 2016 10:40:00 -0400
changeset 323759 470551cf10ebceb65c7b36c4fb6d6f51c2974562
parent 323758 a8ef0ccf056ce8956b89cb9d16939c075ae0f167
child 323760 84d924134d1384e94d3227f21915f28b2841a9d7
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, ritu
bugs1256084
milestone47.0a2
Bug 1256084 - Don't force reflow on size mode change. r=heycam, a=ritu
layout/base/nsPresContext.cpp
layout/style/test/chrome/chrome.ini
layout/style/test/chrome/test_display_mode_reflow.html
layout/style/test/display_mode_reflow_iframe.html
layout/style/test/mochitest.ini
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2199,18 +2199,17 @@ NotifyTabSizeModeChanged(TabParent* aTab
 
 void
 nsPresContext::SizeModeChanged(nsSizeMode aSizeMode)
 {
   if (HasCachedStyleData()) {
     nsContentUtils::CallOnAllRemoteChildren(mDocument->GetWindow(),
                                             NotifyTabSizeModeChanged,
                                             &aSizeMode);
-    MediaFeatureValuesChangedAllDocuments(eRestyle_Subtree,
-                                          NS_STYLE_HINT_REFLOW);
+    MediaFeatureValuesChangedAllDocuments(nsRestyleHint(0));
   }
 }
 
 nsCompatibility
 nsPresContext::CompatibilityMode() const
 {
   return Document()->GetCompatibilityMode();
 }
--- a/layout/style/test/chrome/chrome.ini
+++ b/layout/style/test/chrome/chrome.ini
@@ -12,11 +12,12 @@ support-files =
 [test_addSheet.html]
 [test_additional_sheets.html]
 [test_author_specified_style.html]
 [test_bug418986-2.xul]
 [test_bug1157097.html]
 [test_bug1160724.xul]
 [test_bug535806.xul]
 [test_display_mode.html]
+[test_display_mode_reflow.html]
 [test_hover.html]
 skip-if = buildapp == 'mulet'
 [test_moz_document_rules.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/chrome/test_display_mode_reflow.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1256084
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Display Mode</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+
+/** Test for Display Mode **/
+SimpleTest.waitForExplicitFinish();
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+function waitOneEvent(element, name) {
+  return new Promise(function(resolve, reject) {
+    element.addEventListener(name, function listener() {
+      element.removeEventListener(name, listener);
+      resolve();
+    });
+  });
+}
+
+add_task(function* () {
+  yield waitOneEvent(window, "load");
+
+  var iframe = document.getElementById("subdoc");
+  var subdoc = iframe.contentDocument;
+  var style = subdoc.getElementById("style");
+  var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body, "");
+  var win = Services.wm.getMostRecentWindow("navigator:browser");
+
+  var secondDiv = subdoc.getElementById("b");
+  var offsetTop = secondDiv.offsetTop;
+
+  // Test entering the OS's fullscreen mode.
+  var fullScreenEntered = waitOneEvent(win, "sizemodechange");
+  synthesizeKey("VK_F11", {});
+  yield fullScreenEntered;
+  ok(offsetTop !== secondDiv.offsetTop, "offset top changes");
+  var fullScreenExited = waitOneEvent(win, "sizemodechange");
+  synthesizeKey("VK_F11", {});
+  yield fullScreenExited;
+  ok(offsetTop === secondDiv.offsetTop, "offset top returns to original value");
+
+  offsetTop = secondDiv.offsetTop;
+  // Test entering fullscreen through document requestFullScreen.
+  fullScreenEntered = waitOneEvent(document, "mozfullscreenchange");
+  document.body.mozRequestFullScreen();
+  yield fullScreenEntered
+  ok(offsetTop !== secondDiv.offsetTop, "offset top changes");
+  fullScreenExited = waitOneEvent(document, "mozfullscreenchange");
+  document.mozCancelFullScreen();
+  yield fullScreenExited;
+  ok(offsetTop === secondDiv.offsetTop, "offset top returns to original value");
+});
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1256084">Mozilla Bug 1256084</a>
+<iframe id="subdoc" src="http://mochi.test:8888/tests/layout/style/test/display_mode_reflow_iframe.html"></iframe>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/style/test/display_mode_reflow_iframe.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
+  "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en-US">
+<head>
+  <title>Display Mode Reflow inner frame</title>
+  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  <meta http-equiv="Content-Style-Type" content="text/css">
+  <style type="text/css" id="style" media="all">
+  div {
+    border: 2px solid black;
+    width: 50px;
+    height: 50px;
+  }
+  @media (display-mode: fullscreen) {
+    #a { height: 100px; }
+  }
+  </style>
+</head>
+<body>
+  <div id="a"></div>
+  <div id="b"></div>
+</body>
+</html>
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -4,16 +4,17 @@ support-files =
   ccd-quirks.html
   ccd.sjs
   ccd-standards.html
   css_properties.js
   chrome/bug418986-2.js
   chrome/match.png
   chrome/mismatch.png
   descriptor_database.js
+  display_mode_reflow_iframe.html
   empty.html
   media_queries_dynamic_xbl_binding.xml
   media_queries_dynamic_xbl_iframe.html
   media_queries_dynamic_xbl_style.css
   media_queries_iframe.html
   neverending_font_load.sjs
   neverending_stylesheet_load.sjs
   post-redirect-1.css