Bug 476063. Only do special fieldsetty stuff with <legend>s that are in a fieldset. r+sr=dbaron

This commit is contained in:
Boris Zbarsky 2009-02-03 09:29:47 -05:00
parent c6f3a7ef09
commit bc1f671260
10 changed files with 157 additions and 2 deletions

@ -4979,6 +4979,7 @@ const nsCSSFrameConstructor::FrameConstructionData*
nsCSSFrameConstructor::FindHTMLData(nsIContent* aContent,
nsIAtom* aTag,
PRInt32 aNameSpaceID,
nsIFrame* aParentFrame,
nsStyleContext* aStyleContext)
{
// Ignore the tag if it's not HTML content and if it doesn't extend (via XBL)
@ -4989,6 +4990,24 @@ nsCSSFrameConstructor::FindHTMLData(nsIContent* aContent,
return nsnull;
}
NS_ASSERTION(!aParentFrame ||
aParentFrame->GetStyleContext()->GetPseudoType() !=
nsCSSAnonBoxes::fieldsetContent ||
aParentFrame->GetParent()->GetType() == nsGkAtoms::fieldSetFrame,
"Unexpected parent for fieldset content anon box");
if (aTag == nsGkAtoms::legend &&
(!aParentFrame ||
(aParentFrame->GetType() != nsGkAtoms::fieldSetFrame &&
aParentFrame->GetStyleContext()->GetPseudoType() !=
nsCSSAnonBoxes::fieldsetContent))) {
// <legend> is only special inside fieldset frames
// 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
// fact that with XBL we could end up with this legend element in some
// totally weird insertion point makes that chancy, I think.
return nsnull;
}
static const FrameConstructionDataByTag sHTMLData[] = {
SIMPLE_TAG_CHAIN(img, nsCSSFrameConstructor::FindImgData),
SIMPLE_TAG_CHAIN(mozgeneratedcontentimage,
@ -6720,7 +6739,8 @@ nsCSSFrameConstructor::ConstructFrameInternal( nsFrameConstructorState& aState,
if (isText) {
data = FindTextData(aParentFrame);
} else {
data = FindHTMLData(aContent, aTag, aNameSpaceID, styleContext);
data = FindHTMLData(aContent, aTag, aNameSpaceID, aParentFrame,
styleContext);
if (!data) {
data = FindXULTagData(aContent, aTag, aNameSpaceID, styleContext);
}

@ -792,6 +792,7 @@ private:
static const FrameConstructionData* FindHTMLData(nsIContent* aContent,
nsIAtom* aTag,
PRInt32 aNameSpaceID,
nsIFrame* aParentFrame,
nsStyleContext* aStyleContext);
// HTML data-finding helper functions
static const FrameConstructionData*

@ -0,0 +1,17 @@
<!DOCTYPE html>
<head>
</head>
<body>
<div style="display: table" id="x">
<div style="display: table-row">
<div style="display: table-cell">1 - 1</div>
<div style="display: table-cell">1 - 2</div>
</div>
<div style="display: table-row">
<div style="display: table-cell">2 - 1</div>
<div style="display: table-cell">2 - 2</div>
</div>
</div>
<div style="border: 2px solid green">This is a test</div>
<span style="border: 2px solid green">before<div>This is a test</div>after</span>
</body>

@ -0,0 +1,43 @@
<!DOCTYPE html>
<head>
<script>
function doTest() {
var l = document.createElement("legend");
l.textContent = "This is a test";
l.style.border = "2px solid green";
l.style.display = "block"
document.body.appendChild(l);
l = document.createElement("legend");
var d = document.createElement("div");
d.textContent = "This is a test";
l.style.border = "2px solid green";
l.style.display = "inline"
l.textContent = "before";
l.appendChild(d);
l.appendChild(document.createTextNode("after"));
document.body.appendChild(l);
var t = document.getElementById("x");
var r = document.createElement("div");
r.style.display = "table-row";
l = document.createElement("legend");
l.textContent = "2 - 1";
l.style.display = "table-cell";
r.appendChild(l);
l = document.createElement("legend");
l.textContent = "2 - 2";
l.style.display = "table-cell";
r.appendChild(l);
t.appendChild(r);
}
</script>
</head>
<body onload="doTest()">
<div style="display: table" id="x">
<div style="display: table-row">
<div style="display: table-cell">1 - 1</div>
<div style="display: table-cell">1 - 2</div>
</div>
</div>
</body>

@ -0,0 +1,23 @@
<!DOCTYPE html>
<head>
<script>
function doTest() {
var d = document.createElement("div");
d.textContent = "This is a test";
var l = document.getElementById("l");
l.textContent = "before";
l.appendChild(d);
l.appendChild(document.createTextNode("after"));
}
</script>
</head>
<body onload="doTest()">
<fieldset>
<legend style="border: 2px solid green">This is a test</legend>
First fieldset
</fieldset>
<fieldset>
<legend id="l" style="border: 2px solid green"></legend>
First fieldset
</fieldset>
</body>

@ -0,0 +1,30 @@
<!DOCTYPE html>
<head>
<script>
function doTest() {
var l = document.createElement("legend");
l.textContent = "This is a test";
l.style.border = "2px solid green";
l.style.display = "block"
document.getElementById("f1").appendChild(l);
l = document.createElement("legend");
var d = document.createElement("div");
d.textContent = "This is a test";
l.style.border = "2px solid green";
l.style.display = "inline"
l.textContent = "before";
l.appendChild(d);
l.appendChild(document.createTextNode("after"));
document.getElementById("f2").appendChild(l);
}
</script>
</head>
<body onload="doTest()">
<fieldset id="f1">
First fieldset
</fieldset>
<fieldset id="f2">
First fieldset
</fieldset>
</body>

@ -0,0 +1,9 @@
<!DOCTYPE html>
<head>
</head>
<body>
<fieldset>
<span style="border: 2px solid green;">Legend</span>
First fieldset
</fieldset>
</body>

@ -0,0 +1,9 @@
<!DOCTYPE html>
<head>
</head>
<body>
<fieldset>
<legend style="border: 2px solid green; display: inline; padding: 0">Legend</legend>
First fieldset
</fieldset>
</body>

@ -1035,3 +1035,6 @@ fails == 461512-1.html 461512-1-ref.html # Bug 461512
== 474336-1.xul 474336-1-ref.xul
== 474417-1.html 474417-1-ref.html
== 474472-1.html 474472-1-ref.html
== 476063-1.html 476063-1-ref.html
== 476063-2.html 476063-2-ref.html
!= 476063-3.html 476063-3-ref.html

@ -49,7 +49,7 @@
/* miscellaneous form elements */
legend {
fieldset > legend {
padding-left: 2px;
padding-right: 2px;
border: none;