added css loader support

added insert style sheet support


git-svn-id: svn://10.0.0.236/trunk@32140 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
peterl%netscape.com
1999-05-18 23:06:31 +00:00
parent 16649009d7
commit 77dcc5b017
4 changed files with 42 additions and 66 deletions

View File

@@ -53,6 +53,7 @@
#include "nsIDOMHTMLBodyElement.h"
#include "nsINameSpaceManager.h"
#include "nsGenericDOMNodeList.h"
#include "nsICSSLoader.h"
#ifdef PCB_USE_PROTOCOL_CONNECTION
// beard: how else would we get the referrer to a URL?
@@ -118,6 +119,7 @@ nsHTMLDocument::nsHTMLDocument()
mParser = nsnull;
nsHTMLAtoms::AddrefAtoms();
mDTDMode = eDTDMode_NoQuirks;
mCSSLoader = nsnull;
// Find/Search Init
mSearchStr = nsnull;
@@ -168,6 +170,7 @@ nsHTMLDocument::~nsHTMLDocument()
NS_RELEASE(map);
}
NS_IF_RELEASE(mForms);
NS_IF_RELEASE(mCSSLoader);
// XXX don't bother doing this until the dll is unloaded???
// nsHTMLAtoms::ReleaseAtoms();
@@ -503,39 +506,10 @@ void nsHTMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet) // subclass h
}
}
NS_IMETHODIMP
nsHTMLDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify)
void
nsHTMLDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
{
NS_PRECONDITION(nsnull != aSheet, "null ptr");
mStyleSheets.InsertElementAt(aSheet, aIndex + 1); // offset one for the attr style sheet
NS_ADDREF(aSheet);
aSheet->SetOwningDocument(this);
PRBool enabled = PR_TRUE;
aSheet->GetEnabled(enabled);
PRInt32 count;
PRInt32 index;
if (enabled) {
count = mPresShells.Count();
for (index = 0; index < count; index++) {
nsIPresShell* shell = (nsIPresShell*)mPresShells.ElementAt(index);
nsCOMPtr<nsIStyleSet> set;
shell->GetStyleSet(getter_AddRefs(set));
if (set) {
set->AddDocStyleSheet(aSheet, this);
}
}
}
if (aNotify) { // notify here even if disabled, there may have been others that weren't notified
count = mObservers.Count();
for (index = 0; index < count; index++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(index);
observer->StyleSheetAdded(this, aSheet);
}
}
return NS_OK;
}
@@ -604,6 +578,18 @@ nsHTMLDocument:: SetBaseTarget(const nsString& aTarget)
return NS_OK;
}
NS_IMETHODIMP
nsHTMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
{
nsresult result = NS_OK;
if (! mCSSLoader) {
result = NS_NewCSSLoader(this, &mCSSLoader);
}
aLoader = mCSSLoader;
NS_IF_ADDREF(aLoader);
return result;
}
NS_IMETHODIMP
nsHTMLDocument::GetDTDMode(nsDTDMode& aMode)