Bug 534293 - Make speculative loads initiated by the HTML5 parser take <base> into account. r=jst, a=blocking2.0-betaN.
This commit is contained in:
@@ -830,7 +830,18 @@ nsHtml5TreeOpExecutor::InitializeDocWriteParserState(nsAHtml5TreeBuilderState* a
|
||||
already_AddRefed<nsIURI>
|
||||
nsHtml5TreeOpExecutor::ConvertIfNotPreloadedYet(const nsAString& aURL)
|
||||
{
|
||||
nsIURI* base = mDocument->GetDocBaseURI();
|
||||
// The URL of the document without <base>
|
||||
nsIURI* documentURI = mDocument->GetDocumentURI();
|
||||
// The URL of the document with non-speculative <base>
|
||||
nsIURI* documentBaseURI = mDocument->GetDocBaseURI();
|
||||
|
||||
// If the two above are different, use documentBaseURI. If they are the
|
||||
// same, the document object isn't aware of a <base>, so attempt to use the
|
||||
// mSpeculationBaseURI or, failing, that, documentURI.
|
||||
nsIURI* base = (documentURI == documentBaseURI) ?
|
||||
(mSpeculationBaseURI ?
|
||||
mSpeculationBaseURI.get() : documentURI)
|
||||
: documentBaseURI;
|
||||
const nsCString& charset = mDocument->GetDocumentCharacterSet();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL, charset.get(), base);
|
||||
@@ -882,6 +893,21 @@ nsHtml5TreeOpExecutor::PreloadImage(const nsAString& aURL)
|
||||
mDocument->MaybePreLoadImage(uri);
|
||||
}
|
||||
|
||||
void
|
||||
nsHtml5TreeOpExecutor::SetSpeculationBase(const nsAString& aURL)
|
||||
{
|
||||
if (mSpeculationBaseURI) {
|
||||
// the first one wins
|
||||
return;
|
||||
}
|
||||
const nsCString& charset = mDocument->GetDocumentCharacterSet();
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(mSpeculationBaseURI), aURL,
|
||||
charset.get(), mDocument->GetDocumentURI());
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to create a URI");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
|
||||
PRUint32 nsHtml5TreeOpExecutor::sAppendBatchMaxSize = 0;
|
||||
PRUint32 nsHtml5TreeOpExecutor::sAppendBatchSlotsExamined = 0;
|
||||
|
||||
Reference in New Issue
Block a user