Bug 548263 - Copied the HTML Content sink code for handling rel value to the XML Content sink; r=hsivonen

This commit is contained in:
Danilo Shiga 2011-08-29 17:26:23 +01:00
parent 6dca5e5eaf
commit fb306dc4e6

View File

@ -647,14 +647,28 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
}
}
// Look for <link rel="dns-prefetch" href="hostname">
// and look for <link rel="next" href="hostname"> like in HTML sink
if (nodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
nsAutoString relVal;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
if (relVal.EqualsLiteral("dns-prefetch")) {
nsAutoString hrefVal;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchDNS(hrefVal);
if (!relVal.IsEmpty()) {
// XXX seems overkill to generate this string array
nsAutoTArray<nsString, 4> linkTypes;
nsStyleLinkElement::ParseLinkTypes(relVal, linkTypes);
PRBool hasPrefetch = linkTypes.Contains(NS_LITERAL_STRING("prefetch"));
if (hasPrefetch || linkTypes.Contains(NS_LITERAL_STRING("next"))) {
nsAutoString hrefVal;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchHref(hrefVal, aContent, hasPrefetch);
}
}
if (linkTypes.Contains(NS_LITERAL_STRING("dns-prefetch"))) {
nsAutoString hrefVal;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchDNS(hrefVal);
}
}
}
}