Revert the change to RequiresBody. In particular, an <input type="Hidden"> needs to not require it, for now... Bug 418464, r+sr=mrbkap, a=jonas

This commit is contained in:
bzbarsky@mit.edu 2008-03-05 12:46:21 -08:00
parent e31ee13acf
commit ed92494ec4
4 changed files with 103 additions and 4 deletions

View File

@ -479,6 +479,52 @@ CNavDTD::GetType()
return NS_IPARSER_FLAG_HTML;
}
/**
* Text and some tags require a body when they're added, this function returns
* true for those tags.
*
* @param aToken The current token that we care about.
* @param aTokenizer A tokenizer that we can get the tags attributes off of.
* @return PR_TRUE if aToken does indeed force the body to open.
*/
static PRBool
DoesRequireBody(CToken* aToken, nsITokenizer* aTokenizer)
{
PRBool result = PR_FALSE;
if (aToken) {
eHTMLTags theTag = (eHTMLTags)aToken->GetTypeID();
if (gHTMLElements[theTag].HasSpecialProperty(kRequiresBody)) {
if (theTag == eHTMLTag_input) {
// IE & Nav4x opens up a body for type=text - Bug 66985
// XXXbz but we don't want to open one for <input> with no
// type attribute? That's pretty whack.
PRInt32 ac = aToken->GetAttributeCount();
for(PRInt32 i = 0; i < ac; ++i) {
CAttributeToken* attr = static_cast<CAttributeToken*>
(aTokenizer->GetTokenAt(i));
const nsSubstring& name = attr->GetKey();
const nsAString& value = attr->GetValue();
// XXXbz note that this stupid case-sensitive comparison is
// actually depended on by sites...
if ((name.EqualsLiteral("type") ||
name.EqualsLiteral("TYPE"))
&&
!(value.EqualsLiteral("hidden") ||
value.EqualsLiteral("HIDDEN"))) {
result = PR_TRUE;
break;
}
}
} else {
result = PR_TRUE;
}
}
}
return result;
}
static PRBool
ValueIsHidden(const nsAString& aValue)
{
@ -690,10 +736,7 @@ CNavDTD::HandleToken(CToken* aToken, nsIParser* aParser)
// end tag.
}
if (gHTMLElements[theTag].HasSpecialProperty(kRequiresBody) &&
(theTag != eHTMLTag_input ||
theType != eToken_start ||
!IsHiddenInput(aToken, mTokenizer))) {
if (DoesRequireBody(aToken, mTokenizer)) {
CToken* theBodyToken =
mTokenAllocator->CreateTokenOfType(eToken_start,
eHTMLTag_body,

View File

@ -54,6 +54,7 @@ _TEST_FILES = parser_datreader.js \
test_bug339350.xhtml \
test_bug358797.html \
test_bug396568.html \
test_bug418464.html \
test_compatmode.html \
regressions.txt \
$(NULL)

View File

@ -343,9 +343,21 @@ x { content:"</style" } "
| <!DOCTYPE HTML>
| <html>
| <head>
| <frameset>
| rows="*"
| <frame>
#data
<!DOCTYPE html><html><head></head><form><input type="text"></form><frameset rows="*"><frame></frameset></html>
#errors
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <body>
| <form>
| <input>
| type="text"
#data
<!DOCTYPE html><html><head></head><form><input type="hidden"></form><frameset rows="*"><frame></frameset></html>

View File

@ -0,0 +1,43 @@
<form name="formGo" method="post">
<input type="hidden">
</form>
<script>
var form1 = document.formGo;
</script>
<form name="formGo2" method="post">
<input type="Hidden">
</form>
<script>
var form2 = document.formGo2;
</script>
<!-- NOTE: The forms and scripts above this comment _must_ come first in this file-->
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=418464
-->
<head>
<title>Test for Bug 418464</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=418464">Mozilla Bug 418464</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 418464 **/
is(form1, undefined, "Should not have a form here");
is(form2 instanceof HTMLFormElement, true,
"Should have a form here");
</script>
</pre>
</body>
</html>