96364 - Register html tag observers directly to parser service rather than nsObserverService. Doing so, reduces a lot of overhead. Also, the observers are now notified via sink. This eliminates the need for parser bundle.
r=dp,shanjian,sfraser, sr=rpotts. git-svn-id: svn://10.0.0.236/trunk@104152 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -158,6 +158,7 @@ const PRBool kBlockByDefault=PR_TRUE;
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
static NS_DEFINE_IID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -239,6 +240,7 @@ public:
|
||||
NS_IMETHOD DidProcessTokens(void);
|
||||
NS_IMETHOD WillProcessAToken(void);
|
||||
NS_IMETHOD DidProcessAToken(void);
|
||||
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode);
|
||||
|
||||
|
||||
// nsIHTMLContentSink
|
||||
@@ -416,6 +418,8 @@ public:
|
||||
PRInt32 mDynamicIntervalSwitchThreshold; // Switch between intervals when time is exceeded
|
||||
PRInt32 mBeginLoadTime;
|
||||
|
||||
nsCOMPtr<nsIObserverEntry> mObservers;
|
||||
|
||||
void StartLayout();
|
||||
|
||||
void ScrollToRef();
|
||||
@@ -907,8 +911,6 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
||||
return rv;
|
||||
}
|
||||
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
|
||||
nsresult
|
||||
NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo, PRBool aCaseSensitive)
|
||||
{
|
||||
@@ -2498,6 +2500,17 @@ HTMLContentSink::Init(nsIDocument* aDoc,
|
||||
mWebShell = aContainer;
|
||||
NS_ADDREF(aContainer);
|
||||
|
||||
mObservers = nsnull;
|
||||
|
||||
nsCOMPtr<nsIParserService> service(do_GetService(kParserServiceCID));
|
||||
|
||||
if (!service) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
service->GetTopicObservers(NS_LITERAL_STRING("text/html"),
|
||||
getter_AddRefs(mObservers));
|
||||
|
||||
nsCOMPtr<nsIScriptLoader> loader;
|
||||
rv = mDocument->GetScriptLoader(getter_AddRefs(loader));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@@ -3833,6 +3846,13 @@ PRInt32 newMaxTokenProcessingTime = GetMaxTokenProcessingTime();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#include "nsIElementObserver.h"
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::NotifyTagObservers(nsIParserNode* aNode)
|
||||
{
|
||||
return mObservers? mObservers->Notify(aNode,mParser,mWebShell) : NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLContentSink::StartLayout()
|
||||
|
||||
@@ -582,22 +582,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
NS_PRECONDITION(nsnull != aContainer, "No content viewer container");
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
|
||||
|
||||
if(mParser) {
|
||||
nsCOMPtr<nsISupportsParserBundle> parserBundle;
|
||||
nsresult result;
|
||||
|
||||
parserBundle = do_QueryInterface(mParser, &result);
|
||||
|
||||
if(NS_SUCCEEDED(result)) {
|
||||
// We do this to help consumers who don't have access to the webshell.
|
||||
nsAutoString theDocShell,theChannel;
|
||||
theDocShell.AssignWithConversion("docshell");
|
||||
theChannel.AssignWithConversion("channel");
|
||||
parserBundle->SetDataIntoBundle(theDocShell,docShell);
|
||||
parserBundle->SetDataIntoBundle(theChannel,aChannel);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
|
||||
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
#ifdef IBMBIDI
|
||||
|
||||
@@ -116,6 +116,7 @@ public:
|
||||
NS_IMETHOD DidProcessTokens(void) { return NS_OK; }
|
||||
NS_IMETHOD WillProcessAToken(void) { return NS_OK; }
|
||||
NS_IMETHOD DidProcessAToken(void) { return NS_OK; }
|
||||
NS_IMETHOD NotifyTagObservers(nsIParserNode* aNode) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD DoFragment(PRBool aFlag);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user