Bug 1140579 - Make <legend>s have a legend frame when nearest ancestor frame is a fieldset frame. r=roc
authorMats Palmgren <mats@mozilla.com>
Sat, 07 Mar 2015 14:53:46 +0000
changeset 232391 8e4e3a618c9ce87929f97f68c0b6b2c05e5b7253
parent 232390 a3053a836a09a719bceac3d8ffe3f9e866e2c436
child 232392 322d60fc413ea6c275a90030c66d206d77cec6e0
push id56536
push usermpalmgren@mozilla.com
push dateSat, 07 Mar 2015 14:58:04 +0000
treeherdermozilla-inbound@8e4e3a618c9c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1140579
milestone39.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 1140579 - Make <legend>s have a legend frame when nearest ancestor frame is a fieldset frame. r=roc IOW, drop the requirement that the parent *content* is a <fieldset>, thus allowing a <legend> to become the fieldset legend also when it's wrapped in one or more nodes that are styled with display:contents.
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/css-display/display-contents-fieldset-ref.html
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3466,18 +3466,16 @@ nsCSSFrameConstructor::FindHTMLData(Elem
   NS_ASSERTION(!aParentFrame ||
                aParentFrame->StyleContext()->GetPseudo() !=
                  nsCSSAnonBoxes::fieldsetContent ||
                aParentFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame,
                "Unexpected parent for fieldset content anon box");
   if (aTag == nsGkAtoms::legend &&
       (!aParentFrame ||
        !IsFrameForFieldSet(aParentFrame, aParentFrame->GetType()) ||
-       !aElement->GetParent() ||
-       !aElement->GetParent()->IsHTMLElement(nsGkAtoms::fieldset) ||
        aStyleContext->StyleDisplay()->IsFloatingStyle() ||
        aStyleContext->StyleDisplay()->IsAbsolutelyPositionedStyle())) {
     // <legend> is only special inside fieldset, check both the frame tree
     // parent and content tree parent due to XBL issues. For floated or
     // absolutely positioned legends we want to construct by display type and
     // not do special legend stuff.
     // XXXbz it would be nice if we could just decide this based on the parent
     // tag, and hence just use a SIMPLE_TAG_CHAIN for legend below, but the
--- a/layout/reftests/css-display/display-contents-fieldset-ref.html
+++ b/layout/reftests/css-display/display-contents-fieldset-ref.html
@@ -9,36 +9,37 @@ legend { border: 1px solid; }
 .test2 legend::after, .test3 legend::after { content:"legend"; }
 .test2 legend.static, .test3 legend.static { display:block; }
 .test2 legend.static::before, .test3 legend.static::before { content:"static "; }
 .test2 legend.static::before { content:"static "; }
 .after::after { content:"::after"; }
 .before::before { content:"::before"; }
 .nb legend.static  { border: 1px solid; }
 .nb legend { border-style:none; }
+.p0 legend { padding:0; }
 </style>
 </head>
 <body>
 <fieldset><div class="test contents"></div></fieldset>
 <fieldset><div class="test contents">x</div></fieldset>
 <fieldset><div class="test contents after"></div></fieldset>
 <fieldset><div class="test contents before"></div></fieldset>
 <fieldset><div class="test contents before after"></div></fieldset>
 <fieldset><legend class="test contents"></legend></fieldset>
-<fieldset><div class="contents nb"><legend class="test contents"></legend></div></fieldset>
+<fieldset><legend class="test contents" style="padding:0"></legend></fieldset>
 <fieldset><legend class="contents"><div class="test contents"></div></legend></fieldset>
 <fieldset class="test2"></fieldset>
 <fieldset class="test2 after"></fieldset>
 <fieldset class="test2"><legend class="static"></legend></fieldset>
 <fieldset class="test2"><legend class="static contents"></legend></fieldset>
-<fieldset class="test2"><div class="contents"><legend class="static"></legend></div></fieldset>
-<fieldset><div class="test2 contents nb"></div></fieldset>
-<fieldset><div class="test3 contents"></div></fieldset>
-<fieldset><div class="test2 contents nb"><legend class="static"></legend></div></fieldset>
-<fieldset><div class="test3 contents"><legend class="static"></legend></div></fieldset>
+<fieldset class="test2"><legend class="static" style="padding:0"></legend></fieldset>
+<fieldset class="test2 p0"></fieldset>
+<fieldset class="test2 p0"></fieldset>
+<fieldset class="test2 p0"><legend class="static"></legend></fieldset>
+<fieldset class="test2 p0"><legend class="static"></legend></fieldset>
 <script>
 document.body.offsetHeight;
 var tests = document.querySelectorAll('.test');
 for (i=0; i < tests.length; ++i) {
   test = tests[i];
   test.appendChild(document.createElement('span'));
 }
 var tests = document.querySelectorAll('.test2,.test3');