Don't ship link to the head from <body>. <link> and <style> will still prefer the head in the absense of an explicit body, but will stay still if there is one. bug 387691, r=sicking/sayrer sr=jst

This commit is contained in:
mrbkap@gmail.com 2007-07-20 17:40:59 -07:00
Родитель 804f30a419
Коммит d41b2caa57
9 изменённых файлов: 90 добавлений и 19 удалений

Просмотреть файл

@ -622,7 +622,9 @@ CNavDTD::HandleToken(CToken* aToken, nsIParser* aParser)
PRBool isExclusive = PR_FALSE;
PRBool theChildBelongsInHead =
gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag, isExclusive);
if (theChildBelongsInHead && !isExclusive) {
if (theChildBelongsInHead &&
!isExclusive &&
!gHTMLElements[theTag].HasSpecialProperty(kPreferHead)) {
if (mMisplacedContent.GetSize() == 0 &&
(!gHTMLElements[theTag].HasSpecialProperty(kPreferBody) ||
(mFlags & NS_DTD_FLAG_HAS_EXPLICIT_HEAD))) {

Просмотреть файл

@ -790,8 +790,8 @@ const nsHTMLElement gHTMLElements[] = {
/*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
/*rootnodes,endrootnodes*/ &gInHead,&gInHead,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kHeadContent, kNone, kNone,
/*special props, prop-range*/ kNonContainer,kDefaultPropRange,
/*parent,incl,exclgroups*/ kAllTags - kHeadContent, kNone, kNone,
/*special props, prop-range*/ kNonContainer|kPreferHead,kDefaultPropRange,
/*special parents,kids,skip*/ &gInHead,0,eHTMLTag_unknown,
/*contain-func*/ 0
},
@ -1089,7 +1089,7 @@ const nsHTMLElement gHTMLElements[] = {
/*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
/*autoclose starttags and endtags*/ 0,0,0,0,
/*parent,incl,exclgroups*/ kAllTags - kHeadContent, kCDATA, kNone,
/*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange,
/*special props, prop-range*/ kNoStyleLeaksIn|kPreferHead, kNoPropRange,
/*special parents,kids,skip*/ 0,0,eHTMLTag_unknown,
/*contain-func*/ 0
},

Просмотреть файл

@ -272,5 +272,6 @@ static const int kNonContainer = 0x0200; //If set, then this tag is not a co
static const int kHandleStrayTag = 0x0400; //If set, we automatically open a start tag
static const int kRequiresBody = 0x0800; //If set, then in case of no BODY one will be opened up immediately.
static const int kVerifyHierarchy = 0x1000; //If set, check to see if the tag is a child or a sibling..
static const int kPreferHead = 0x2000; //This kHeadMisc tag prefers to be in the head if there isn't an explicit <body>
#endif

Просмотреть файл

@ -53,7 +53,7 @@ _TEST_FILES = parser_datreader.js \
test_html5_tree_construction.html \
test_bug339350.xhtml \
test_bug358797.html \
bug379025.txt \
regressions.txt \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -1,10 +0,0 @@
#data
<!DOCTYPE html><html><head><noscript></noscript><style></style></head><frameset></frameset>
#errors
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <noscript>
| <style>
| <frameset>

Просмотреть файл

@ -65,5 +65,7 @@ var html5Exceptions = {
"<!doctype html><!--x--": true,
"<head></head><!-- --><style></style><!-- --><script></script>": true,
"<head></head><!-- -->x<style></style><!-- --><script></script>": true,
"<body><body><base><link><meta><title><p></title><body><p></body>": true,
"<!doctype html><body><title>X</title><meta name=z><link rel=foo><style>\nx { content:\"</style\" } </style>": true,
}

Просмотреть файл

@ -57,7 +57,7 @@ function writeErrorSummary(input, expected, got, isTodo) {
SPAN("Matched: "), "" + (expected == got),
P("Input: " + input),
PRE("Expected:\n|" + expected +"|", "\n-\n",
"Output:\n|" + got + "|\n\n"),
"Output:\n|" + got + "|\n\n"),
HR()
);
}
@ -79,9 +79,9 @@ function makeTestChecker(input, expected, errors) {
todo(reorderedDOM == expected, "HTML5 expected failure. " + new Date());
writeErrorSummary(input, expected, reorderedDOM, true);
} else {
if (reorderedDOM != expected) {
if (reorderedDOM != expected) {
is(reorderedDOM, expected, "HTML5 unexpected failure. " + input + " " + new Date());
writeErrorSummary(input, expected, reorderedDOM, false);
writeErrorSummary(input, expected, reorderedDOM, false);
} else {
is(reorderedDOM, expected, "HTML5 expected success. " + new Date());
}

Просмотреть файл

@ -0,0 +1,76 @@
#data
<!DOCTYPE html><html><head><noscript></noscript><style></style></head><frameset></frameset>
#errors
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <noscript>
| <style>
| <frameset>
#data
<!DOCTYPE html><html><head><link><body></body></html>
#errors
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <link>
| <body>
#data
<!DOCTYPE html><html><link><body>#</body></html>
#errors
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <link>
| <body>
| "#"
#data
<body><body><base><link><meta><title><p></title><body><p>#</body>
#errors
6: missing document type declaration
12: unexpected body element start tag
18: base element start tag out of place
24: link element start tag out of place
30: meta element start tag out of place
37: title element start tag out of place
54: unexpected body element start tag
#document
| <html>
| <head>
| <base>
| <meta>
| <title>
| "<p>"
| <body>
| <link>
| <p>
| "#"
#data
<!doctype html><body><title>X</title><meta name=y><link rel=foo><style>
x { content:"</style" } </style>
#errors
Unexpected start tag that belongs in head.
Unexpected start tag that belongs in head.
Unexpected start tag that belongs in head.
Expected closing tag after </.
#document
| <!DOCTYPE HTML>
| <html>
| <head>
| <title>
| "X"
| <meta>
| name="y"
| <body>
| <link>
| rel="foo"
| <style>
| "
x { content:"</style" } "

Просмотреть файл

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
var parserDatFiles = ["html5lib_tree_dat1.txt",
"html5lib_tree_dat2.txt",
"html5lib_tree_dat3.txt",
"bug379025.txt"];
"regressions.txt"];
</script>
<script type="application/javascript;version=1.7"
src="parser_web_testrunner.js"></script>