Bug 684469 - Various cleanup in nsHtml5TreeOpExecutor; r=hsivonen
This commit is contained in:
@@ -58,6 +58,9 @@
|
||||
#include "nsHtml5TreeBuilder.h"
|
||||
#include "nsHtml5StreamParser.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "mozilla/Util.h" // DebugOnly
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsHtml5TreeOpExecutor)
|
||||
|
||||
@@ -131,7 +134,7 @@ nsHtml5TreeOpExecutor::DidBuildModel(PRBool aTerminated)
|
||||
}
|
||||
}
|
||||
|
||||
static_cast<nsHtml5Parser*> (mParser.get())->DropStreamParser();
|
||||
GetParser()->DropStreamParser();
|
||||
|
||||
// This comes from nsXMLContentSink and nsHTMLContentSink
|
||||
DidBuildModelImpl(aTerminated);
|
||||
@@ -269,7 +272,7 @@ nsHtml5TreeOpExecutor::UpdateChildCounts()
|
||||
nsresult
|
||||
nsHtml5TreeOpExecutor::FlushTags()
|
||||
{
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -316,7 +319,7 @@ nsHtml5TreeOpExecutor::UpdateStyleSheet(nsIContent* aElement)
|
||||
mScriptLoader->AddExecuteBlocker();
|
||||
}
|
||||
|
||||
if (aElement->IsHTML() && aElement->Tag() == nsGkAtoms::link) {
|
||||
if (aElement->IsHTML(nsGkAtoms::link)) {
|
||||
// look for <link rel="next" href="url">
|
||||
nsAutoString relVal;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
@@ -356,8 +359,8 @@ nsHtml5TreeOpExecutor::FlushSpeculativeLoads()
|
||||
mStage.MoveSpeculativeLoadsTo(speculativeLoadQueue);
|
||||
const nsHtml5SpeculativeLoad* start = speculativeLoadQueue.Elements();
|
||||
const nsHtml5SpeculativeLoad* end = start + speculativeLoadQueue.Length();
|
||||
for (nsHtml5SpeculativeLoad* iter = (nsHtml5SpeculativeLoad*)start;
|
||||
iter < end;
|
||||
for (nsHtml5SpeculativeLoad* iter = const_cast<nsHtml5SpeculativeLoad*>(start);
|
||||
iter < end;
|
||||
++iter) {
|
||||
iter->Perform(this);
|
||||
}
|
||||
@@ -458,10 +461,10 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
|
||||
// Not sure if this grip is still needed, but previously, the code
|
||||
// gripped before calling ParseUntilBlocked();
|
||||
nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip =
|
||||
static_cast<nsHtml5Parser*> (mParser.get())->GetStreamParser();
|
||||
GetParser()->GetStreamParser();
|
||||
// Now parse content left in the document.write() buffer queue if any.
|
||||
// This may generate tree ops on its own or dequeue a speculation.
|
||||
static_cast<nsHtml5Parser*> (mParser.get())->ParseUntilBlocked();
|
||||
GetParser()->ParseUntilBlocked();
|
||||
}
|
||||
|
||||
if (mOpQueue.IsEmpty()) {
|
||||
@@ -482,7 +485,7 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
|
||||
|
||||
const nsHtml5TreeOperation* first = mOpQueue.Elements();
|
||||
const nsHtml5TreeOperation* last = first + numberOfOpsToFlush - 1;
|
||||
for (nsHtml5TreeOperation* iter = (nsHtml5TreeOperation*)first;;) {
|
||||
for (nsHtml5TreeOperation* iter = const_cast<nsHtml5TreeOperation*>(first);;) {
|
||||
if (NS_UNLIKELY(!mParser)) {
|
||||
// The previous tree op caused a call to nsIParser::Terminate().
|
||||
break;
|
||||
@@ -581,8 +584,8 @@ nsHtml5TreeOpExecutor::FlushDocumentWrite()
|
||||
|
||||
const nsHtml5TreeOperation* start = mOpQueue.Elements();
|
||||
const nsHtml5TreeOperation* end = start + numberOfOpsToFlush;
|
||||
for (nsHtml5TreeOperation* iter = (nsHtml5TreeOperation*)start;
|
||||
iter < end;
|
||||
for (nsHtml5TreeOperation* iter = const_cast<nsHtml5TreeOperation*>(start);
|
||||
iter < end;
|
||||
++iter) {
|
||||
if (NS_UNLIKELY(!mParser)) {
|
||||
// The previous tree op caused a call to nsIParser::Terminate().
|
||||
@@ -663,7 +666,7 @@ nsHtml5TreeOpExecutor::StartLayout() {
|
||||
|
||||
EndDocUpdate();
|
||||
|
||||
if(NS_UNLIKELY(!mParser)) {
|
||||
if (NS_UNLIKELY(!mParser)) {
|
||||
// got terminate
|
||||
return;
|
||||
}
|
||||
@@ -774,7 +777,7 @@ nsHtml5TreeOpExecutor::NeedsCharsetSwitchTo(const char* aEncoding,
|
||||
{
|
||||
EndDocUpdate();
|
||||
|
||||
if(NS_UNLIKELY(!mParser)) {
|
||||
if (NS_UNLIKELY(!mParser)) {
|
||||
// got terminate
|
||||
return;
|
||||
}
|
||||
@@ -796,15 +799,21 @@ nsHtml5TreeOpExecutor::NeedsCharsetSwitchTo(const char* aEncoding,
|
||||
return;
|
||||
}
|
||||
|
||||
(static_cast<nsHtml5Parser*> (mParser.get()))->ContinueAfterFailedCharsetSwitch();
|
||||
GetParser()->ContinueAfterFailedCharsetSwitch();
|
||||
|
||||
BeginDocUpdate();
|
||||
}
|
||||
|
||||
nsHtml5Parser*
|
||||
nsHtml5TreeOpExecutor::GetParser()
|
||||
{
|
||||
return static_cast<nsHtml5Parser*>(mParser.get());
|
||||
}
|
||||
|
||||
nsHtml5Tokenizer*
|
||||
nsHtml5TreeOpExecutor::GetTokenizer()
|
||||
{
|
||||
return (static_cast<nsHtml5Parser*> (mParser.get()))->GetTokenizer();
|
||||
return GetParser()->GetTokenizer();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -844,7 +853,7 @@ nsHtml5TreeOpExecutor::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue)
|
||||
void
|
||||
nsHtml5TreeOpExecutor::InitializeDocWriteParserState(nsAHtml5TreeBuilderState* aState, PRInt32 aLine)
|
||||
{
|
||||
static_cast<nsHtml5Parser*> (mParser.get())->InitializeDocWriteParserState(aState, aLine);
|
||||
GetParser()->InitializeDocWriteParserState(aState, aLine);
|
||||
}
|
||||
|
||||
// Speculative loading
|
||||
@@ -877,9 +886,7 @@ nsHtml5TreeOpExecutor::ConvertIfNotPreloadedYet(const nsAString& aURL)
|
||||
return nsnull;
|
||||
}
|
||||
mPreloadedURLs.Put(spec);
|
||||
nsIURI* retURI = uri;
|
||||
NS_ADDREF(retURI);
|
||||
return retURI;
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -924,11 +931,9 @@ nsHtml5TreeOpExecutor::SetSpeculationBase(const nsAString& aURL)
|
||||
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");
|
||||
}
|
||||
DebugOnly<nsresult> rv = NS_NewURI(getter_AddRefs(mSpeculationBaseURI), aURL,
|
||||
charset.get(), mDocument->GetDocumentURI());
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to create a URI");
|
||||
}
|
||||
|
||||
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
|
||||
|
||||
Reference in New Issue
Block a user