Bug 1246185 - Do not collapsed <details> when preference off. r=bz draft
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 09 Feb 2016 14:07:01 +0800
changeset 329753 947a1faac9cd3e2bd9185fcac5b08f87cc471e37
parent 329566 815d689a6e1e7187b10238f2f840d49201d67c2b
child 514025 c1c24568f315ab14941ccb3f2ffc19b254dda3e8
push id10597
push usertlin@mozilla.com
push dateTue, 09 Feb 2016 06:20:00 +0000
reviewersbz
bugs1246185
milestone47.0a1
Bug 1246185 - Do not collapsed <details> when preference off. r=bz To retain backward compatibility, <details> tags should not collapse its children when dom.details_element.enabled = false.
dom/html/HTMLDetailsElement.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/details-summary/disabled-no-summary-ref.html
layout/reftests/details-summary/disabled-single-summary-ref.html
layout/reftests/details-summary/reftest.list
--- a/dom/html/HTMLDetailsElement.cpp
+++ b/dom/html/HTMLDetailsElement.cpp
@@ -19,17 +19,17 @@ NS_NewHTMLDetailsElement(already_AddRefe
   }
 
   return new mozilla::dom::HTMLDetailsElement(aNodeInfo);
 }
 
 namespace mozilla {
 namespace dom {
 
-bool
+/* static */ bool
 HTMLDetailsElement::IsDetailsEnabled()
 {
   static bool isDetailsEnabled = false;
   static bool added = false;
 
   if (!added) {
     Preferences::AddBoolVarCache(&isDetailsEnabled,
                                  "dom.details_element.enabled");
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5636,17 +5636,17 @@ nsCSSFrameConstructor::AddFrameConstruct
       }
       return;
     }
   }
 
   // When constructing a child of a non-open <details>, create only the frame
   // for the main <summary> element, and skip other elements.
   auto* details = HTMLDetailsElement::FromContentOrNull(parent);
-  if (details && !details->Open()) {
+  if (details && details->IsDetailsEnabled() && !details->Open()) {
     auto* summary = HTMLSummaryElement::FromContentOrNull(aContent);
     if (!summary || !summary->IsMainSummary()) {
       SetAsUndisplayedContent(aState, aItems, aContent, styleContext,
                               isGeneratedContent);
       return;
     }
   }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/disabled-no-summary-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <body>
+    <div>
+      <p>This is the details.</p>
+    </div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/details-summary/disabled-single-summary-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<!-- Any copyright is dedicated to the Public Domain.
+   - http://creativecommons.org/publicdomain/zero/1.0/ -->
+
+<html>
+  <body>
+    <div>
+      <div>Summary</div>
+      <p>This is the details.</p>
+    </div>
+  </body>
+</html>
--- a/layout/reftests/details-summary/reftest.list
+++ b/layout/reftests/details-summary/reftest.list
@@ -1,8 +1,13 @@
+# Disable <details> and <summary>
+pref(dom.details_element.enabled,false) == single-summary.html disabled-single-summary-ref.html
+pref(dom.details_element.enabled,false) == open-single-summary.html disabled-single-summary-ref.html
+pref(dom.details_element.enabled,false) == no-summary.html disabled-no-summary-ref.html
+
 # Basic <summary> handling
 pref(dom.details_element.enabled,true) == multiple-summary.html single-summary.html
 pref(dom.details_element.enabled,true) == open-multiple-summary.html open-multiple-summary-ref.html
 pref(dom.details_element.enabled,true) == summary-not-first-child.html single-summary.html
 pref(dom.details_element.enabled,true) == open-summary-not-first-child.html open-single-summary.html
 pref(dom.details_element.enabled,true) == open-summary-block-style.html open-single-summary.html
 pref(dom.details_element.enabled,true) == no-summary.html no-summary-ref.html
 pref(dom.details_element.enabled,true) == open-no-summary.html open-no-summary-ref.html