mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
Bug 516422 - Copy link prefetching from nsHTMLContentSink to the HTML5 parser. r=bnewman.
--HG-- extra : rebase_source : c0a5999b05919fa496ddcee94f7be74d004288f3
This commit is contained in:
parent
c22899568e
commit
f0f3e5872b
@ -44,6 +44,7 @@
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIStyleSheetLinkingElement.h"
|
||||
#include "nsStyleLinkElement.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptGlobalObjectOwner.h"
|
||||
@ -295,6 +296,32 @@ nsHtml5TreeOpExecutor::UpdateStyleSheet(nsIContent* aElement)
|
||||
mScriptLoader->AddExecuteBlocker();
|
||||
}
|
||||
|
||||
if (aElement->IsHTML() && aElement->Tag() == nsGkAtoms::link) {
|
||||
// look for <link rel="next" href="url">
|
||||
nsAutoString relVal;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
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;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchHref(hrefVal, aElement, hasPrefetch);
|
||||
}
|
||||
}
|
||||
if (linkTypes.Contains(NS_LITERAL_STRING("dns-prefetch"))) {
|
||||
nsAutoString hrefVal;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchDNS(hrefVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Re-open update
|
||||
BeginDocUpdate();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user