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.
This commit is contained in:
Ting-Yu Lin 2016-02-09 14:07:01 +08:00
parent a3b261fb2e
commit 90ef1eae6a
5 changed files with 30 additions and 2 deletions

View File

@ -24,7 +24,7 @@ NS_NewHTMLDetailsElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
bool /* static */ bool
HTMLDetailsElement::IsDetailsEnabled() HTMLDetailsElement::IsDetailsEnabled()
{ {
static bool isDetailsEnabled = false; static bool isDetailsEnabled = false;

View File

@ -5641,7 +5641,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
// When constructing a child of a non-open <details>, create only the frame // When constructing a child of a non-open <details>, create only the frame
// for the main <summary> element, and skip other elements. // for the main <summary> element, and skip other elements.
auto* details = HTMLDetailsElement::FromContentOrNull(parent); auto* details = HTMLDetailsElement::FromContentOrNull(parent);
if (details && !details->Open()) { if (details && details->IsDetailsEnabled() && !details->Open()) {
auto* summary = HTMLSummaryElement::FromContentOrNull(aContent); auto* summary = HTMLSummaryElement::FromContentOrNull(aContent);
if (!summary || !summary->IsMainSummary()) { if (!summary || !summary->IsMainSummary()) {
SetAsUndisplayedContent(aState, aItems, aContent, styleContext, SetAsUndisplayedContent(aState, aItems, aContent, styleContext,

View File

@ -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>

View File

@ -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>

View File

@ -1,3 +1,8 @@
# 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 # Basic <summary> handling
pref(dom.details_element.enabled,true) == multiple-summary.html single-summary.html 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) == open-multiple-summary.html open-multiple-summary-ref.html