Ensure that the quirks stylesheet is enabled/disabled before we start creating frames so that we don't have to build the rule cascade twice. Remove old compatibility mode pref that only controlled a small part of what it should have. b=141261 sr=waterson r=jst

This commit is contained in:
dbaron%fas.harvard.edu 2002-05-23 23:09:31 +00:00
Родитель be3c4c0281
Коммит 8b60dd54d6
15 изменённых файлов: 112 добавлений и 113 удалений

Просмотреть файл

@ -1824,6 +1824,7 @@ DocumentViewerImpl::SetDOMDocument(nsIDOMDocument *aDocument)
NS_IMETHODIMP NS_IMETHODIMP
DocumentViewerImpl::SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet) DocumentViewerImpl::SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet)
{ {
NS_ASSERTION(aUAStyleSheet, "unexpected null pointer");
if (aUAStyleSheet) { if (aUAStyleSheet) {
nsCOMPtr<nsICSSStyleSheet> sheet(do_QueryInterface(aUAStyleSheet)); nsCOMPtr<nsICSSStyleSheet> sheet(do_QueryInterface(aUAStyleSheet));
nsCOMPtr<nsICSSStyleSheet> newSheet; nsCOMPtr<nsICSSStyleSheet> newSheet;
@ -3838,14 +3839,15 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
} }
#endif // NS_PRINT_PREVIEW #endif // NS_PRINT_PREVIEW
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
// Setup hierarchical relationship in view manager // Setup hierarchical relationship in view manager
aPO->mViewManager->SetRootView(aPO->mRootView); aPO->mViewManager->SetRootView(aPO->mRootView);
aPO->mPresShell->Init(document, aPO->mPresContext, aPO->mPresShell->Init(document, aPO->mPresContext,
aPO->mViewManager, aPO->mStyleSet); aPO->mViewManager, aPO->mStyleSet,
mode != eCompatibility_Standard);
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
aPO->mPresContext->SetCompatibilityMode(mode);
if (!containerIsSet) { if (!containerIsSet) {
nsCOMPtr<nsISupports> supps(do_QueryInterface(aPO->mWebShell)); nsCOMPtr<nsISupports> supps(do_QueryInterface(aPO->mWebShell));
aPO->mPresContext->SetContainer(supps); aPO->mPresContext->SetContainer(supps);

Просмотреть файл

@ -864,9 +864,23 @@ NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable)
} }
} }
} }
NS_ASSERTION(mQuirkStyleSheet, "no quirk stylesheet");
if (mQuirkStyleSheet) { if (mQuirkStyleSheet) {
#if defined(DEBUG_warren) || defined(DEBUG_attinasi) #if defined(DEBUG_warren) || defined(DEBUG_attinasi)
printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" ); printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" );
#endif
#ifdef DEBUG
PRUint32 count = 0;
if (mAgentRuleProcessors)
mAgentRuleProcessors->Count(&count);
PRBool enabledNow;
mQuirkStyleSheet->GetEnabled(enabledNow);
NS_ASSERTION(count == 0 || aEnable == enabledNow,
"enabling/disabling quirk stylesheet too late");
#ifdef DEBUG_dbaron
if (count != 0 && aEnable == enabledNow)
printf("WARNING: We set the quirks mode too many times.\n"); // we do!
#endif
#endif #endif
mQuirkStyleSheet->SetEnabled(aEnable); mQuirkStyleSheet->SetEnabled(aEnable);
} }

Просмотреть файл

@ -495,17 +495,8 @@ nsHTMLDocument::CreateShell(nsIPresContext* aContext,
nsIStyleSet* aStyleSet, nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult) nsIPresShell** aInstancePtrResult)
{ {
nsresult result = nsMarkupDocument::CreateShell(aContext, return doCreateShell(aContext, aViewManager, aStyleSet,
aViewManager, eDTDMode_strict != mDTDMode, aInstancePtrResult);
aStyleSet,
aInstancePtrResult);
if (NS_SUCCEEDED(result)) {
aContext->SetCompatibilityMode(((eDTDMode_strict== mDTDMode) ?
eCompatibility_Standard :
eCompatibility_NavQuirks));
}
return result;
} }
// The following Try*Charset will return PR_FALSE only if the charset source // The following Try*Charset will return PR_FALSE only if the charset source

Просмотреть файл

@ -61,11 +61,22 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet, nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult) nsIPresShell** aInstancePtrResult)
{
// Don't add anything here. Add it to |doCreateShell| instead. This
// exists so nsHTMLDocument can pass PR_TRUE for the 4th parameter
// some of the time.
return doCreateShell(aContext, aViewManager, aStyleSet, PR_FALSE,
aInstancePtrResult);
}
nsresult
nsMarkupDocument::doCreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode,
nsIPresShell** aInstancePtrResult)
{ {
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr"); NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv; nsresult rv;
nsCOMPtr<nsIPresShell> shell(do_CreateInstance(kPresShellCID,&rv)); nsCOMPtr<nsIPresShell> shell(do_CreateInstance(kPresShellCID,&rv));
@ -73,7 +84,7 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext,
return rv; return rv;
} }
rv = shell->Init(this, aContext, aViewManager, aStyleSet); rv = shell->Init(this, aContext, aViewManager, aStyleSet, aIsQuirksMode);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -83,11 +94,6 @@ nsMarkupDocument::CreateShell(nsIPresContext* aContext,
*aInstancePtrResult = shell.get(); *aInstancePtrResult = shell.get();
NS_ADDREF(*aInstancePtrResult); NS_ADDREF(*aInstancePtrResult);
// tell the context the mode we want (always standard, which
// should be correct for everything except HTML)
// nsHTMLDocument overrides this method and sets it differently
aContext->SetCompatibilityMode(eCompatibility_Standard);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -62,6 +62,15 @@ public:
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet, nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult); nsIPresShell** aInstancePtrResult);
protected:
// To allow different implementations to choose the quirks mode
// differently for their |CreateShell| without overriding the whole
// thing.
nsresult doCreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode,
nsIPresShell** aInstancePtrResult);
}; };
#endif /* nsMarkupDocument_h___ */ #endif /* nsMarkupDocument_h___ */

Просмотреть файл

@ -1053,19 +1053,14 @@ nsXULDocument::CreateShell(nsIPresContext* aContext,
nsIPresShell** aInstancePtrResult) nsIPresShell** aInstancePtrResult)
{ {
NS_PRECONDITION(aInstancePtrResult, "null ptr"); NS_PRECONDITION(aInstancePtrResult, "null ptr");
if (! aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsIPresShell* shell; nsIPresShell* shell;
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kPresShellCID, nsresult rv = CallCreateInstance(kPresShellCID, &shell);
nsnull, if (NS_FAILED(rv))
NS_GET_IID(nsIPresShell),
(void**) &shell)))
return rv; return rv;
if (NS_FAILED(rv = shell->Init(this, aContext, aViewManager, aStyleSet))) { rv = shell->Init(this, aContext, aViewManager, aStyleSet, PR_FALSE);
if (NS_FAILED(rv)) {
NS_RELEASE(shell); NS_RELEASE(shell);
return rv; return rv;
} }
@ -1073,9 +1068,6 @@ nsXULDocument::CreateShell(nsIPresContext* aContext,
mPresShells.AppendElement(shell); mPresShells.AppendElement(shell);
*aInstancePtrResult = shell; // addref implicit in CreateInstance() *aInstancePtrResult = shell; // addref implicit in CreateInstance()
// tell the context the mode we want (always standard)
aContext->SetCompatibilityMode(eCompatibility_Standard);
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -1824,6 +1824,7 @@ DocumentViewerImpl::SetDOMDocument(nsIDOMDocument *aDocument)
NS_IMETHODIMP NS_IMETHODIMP
DocumentViewerImpl::SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet) DocumentViewerImpl::SetUAStyleSheet(nsIStyleSheet* aUAStyleSheet)
{ {
NS_ASSERTION(aUAStyleSheet, "unexpected null pointer");
if (aUAStyleSheet) { if (aUAStyleSheet) {
nsCOMPtr<nsICSSStyleSheet> sheet(do_QueryInterface(aUAStyleSheet)); nsCOMPtr<nsICSSStyleSheet> sheet(do_QueryInterface(aUAStyleSheet));
nsCOMPtr<nsICSSStyleSheet> newSheet; nsCOMPtr<nsICSSStyleSheet> newSheet;
@ -3838,14 +3839,15 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO, PRBool aDoCalcShrink)
} }
#endif // NS_PRINT_PREVIEW #endif // NS_PRINT_PREVIEW
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
// Setup hierarchical relationship in view manager // Setup hierarchical relationship in view manager
aPO->mViewManager->SetRootView(aPO->mRootView); aPO->mViewManager->SetRootView(aPO->mRootView);
aPO->mPresShell->Init(document, aPO->mPresContext, aPO->mPresShell->Init(document, aPO->mPresContext,
aPO->mViewManager, aPO->mStyleSet); aPO->mViewManager, aPO->mStyleSet,
mode != eCompatibility_Standard);
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
aPO->mPresContext->SetCompatibilityMode(mode);
if (!containerIsSet) { if (!containerIsSet) {
nsCOMPtr<nsISupports> supps(do_QueryInterface(aPO->mWebShell)); nsCOMPtr<nsISupports> supps(do_QueryInterface(aPO->mWebShell));
aPO->mPresContext->SetContainer(supps); aPO->mPresContext->SetContainer(supps);

Просмотреть файл

@ -125,7 +125,8 @@ public:
NS_IMETHOD Init(nsIDocument* aDocument, NS_IMETHOD Init(nsIDocument* aDocument,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet) = 0; nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode) = 0;
/** /**
* All callers are responsible for calling |Destroy| after calling * All callers are responsible for calling |Destroy| after calling

Просмотреть файл

@ -150,7 +150,6 @@ nsPresContext::nsPresContext()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mCompatibilityMode = eCompatibility_Standard; mCompatibilityMode = eCompatibility_Standard;
mCompatibilityLocked = PR_FALSE;
mWidgetRenderingMode = eWidgetRendering_Gfx; mWidgetRenderingMode = eWidgetRendering_Gfx;
mImageAnimationMode = imgIContainer::kNormalAnimMode; mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode; mImageAnimationModePref = imgIContainer::kNormalAnimMode;
@ -454,27 +453,6 @@ nsPresContext::GetUserPreferences()
mFontScaler = prefInt; mFontScaler = prefInt;
} }
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.compatibility.mode", &prefInt))) {
// XXX this should really be a state on the webshell instead of using prefs
switch (prefInt) {
case 1:
mCompatibilityLocked = PR_TRUE;
mCompatibilityMode = eCompatibility_Standard;
break;
case 2:
mCompatibilityLocked = PR_TRUE;
mCompatibilityMode = eCompatibility_NavQuirks;
break;
case 0: // auto
default:
mCompatibilityLocked = PR_FALSE;
break;
}
}
else {
mCompatibilityLocked = PR_FALSE; // auto
}
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) { if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) {
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
} }
@ -783,18 +761,15 @@ nsPresContext::GetCompatibilityMode(nsCompatibility* aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsPresContext::SetCompatibilityMode(nsCompatibility aMode) nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
{ {
if (! mCompatibilityLocked) { mCompatibilityMode = aMode;
mCompatibilityMode = aMode;
} NS_ENSURE_TRUE(mShell, NS_OK);
// enable/disable the QuirkSheet // enable/disable the QuirkSheet
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::SetCompatibilityMode"); nsCOMPtr<nsIStyleSet> set;
if (mShell) { mShell->GetStyleSet(getter_AddRefs(set));
nsCOMPtr<nsIStyleSet> set; if (set) {
nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); set->EnableQuirkStyleSheet(mCompatibilityMode != eCompatibility_Standard);
if (NS_SUCCEEDED(rv) && set) {
set->EnableQuirkStyleSheet((mCompatibilityMode != eCompatibility_Standard) ? PR_TRUE : PR_FALSE);
}
} }
return NS_OK; return NS_OK;
} }
@ -1477,6 +1452,8 @@ nsPresContext::LoadImage(const nsString& aURL,
rv = content->GetDocument(*getter_AddRefs(document)); rv = content->GetDocument(*getter_AddRefs(document));
// If there is no document, skip the policy check // If there is no document, skip the policy check
// XXXldb This really means the document is being destroyed, so
// perhaps we're better off skipping the load entirely.
if (document) { if (document) {
nsCOMPtr<nsIScriptGlobalObject> globalScript; nsCOMPtr<nsIScriptGlobalObject> globalScript;
rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript));

Просмотреть файл

@ -1057,7 +1057,8 @@ public:
NS_IMETHOD Init(nsIDocument* aDocument, NS_IMETHOD Init(nsIDocument* aDocument,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet); nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode);
NS_IMETHOD Destroy(); NS_IMETHOD Destroy();
NS_IMETHOD AllocateFrame(size_t aSize, void** aResult); NS_IMETHOD AllocateFrame(size_t aSize, void** aResult);
@ -1678,7 +1679,8 @@ NS_IMETHODIMP
PresShell::Init(nsIDocument* aDocument, PresShell::Init(nsIDocument* aDocument,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet) nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode)
{ {
NS_PRECONDITION(nsnull != aDocument, "null ptr"); NS_PRECONDITION(nsnull != aDocument, "null ptr");
NS_PRECONDITION(nsnull != aPresContext, "null ptr"); NS_PRECONDITION(nsnull != aPresContext, "null ptr");
@ -1699,11 +1701,16 @@ PresShell::Init(nsIDocument* aDocument,
mViewManager->SetViewObserver(this); mViewManager->SetViewObserver(this);
// Bind the context to the presentation shell. // Bind the context to the presentation shell.
mPresContext = dont_QueryInterface(aPresContext); mPresContext = aPresContext;
aPresContext->SetShell(this); aPresContext->SetShell(this);
mStyleSet = aStyleSet; mStyleSet = aStyleSet;
// Set the compatibility mode after attaching the pres context and
// style set, but before creating any frames.
mPresContext->SetCompatibilityMode(aIsQuirksMode
? eCompatibility_NavQuirks : eCompatibility_Standard);
mHistoryState = nsnull; mHistoryState = nsnull;
nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull, nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull,

Просмотреть файл

@ -125,7 +125,8 @@ public:
NS_IMETHOD Init(nsIDocument* aDocument, NS_IMETHOD Init(nsIDocument* aDocument,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet) = 0; nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode) = 0;
/** /**
* All callers are responsible for calling |Destroy| after calling * All callers are responsible for calling |Destroy| after calling

Просмотреть файл

@ -150,7 +150,6 @@ nsPresContext::nsPresContext()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();
mCompatibilityMode = eCompatibility_Standard; mCompatibilityMode = eCompatibility_Standard;
mCompatibilityLocked = PR_FALSE;
mWidgetRenderingMode = eWidgetRendering_Gfx; mWidgetRenderingMode = eWidgetRendering_Gfx;
mImageAnimationMode = imgIContainer::kNormalAnimMode; mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode; mImageAnimationModePref = imgIContainer::kNormalAnimMode;
@ -454,27 +453,6 @@ nsPresContext::GetUserPreferences()
mFontScaler = prefInt; mFontScaler = prefInt;
} }
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.compatibility.mode", &prefInt))) {
// XXX this should really be a state on the webshell instead of using prefs
switch (prefInt) {
case 1:
mCompatibilityLocked = PR_TRUE;
mCompatibilityMode = eCompatibility_Standard;
break;
case 2:
mCompatibilityLocked = PR_TRUE;
mCompatibilityMode = eCompatibility_NavQuirks;
break;
case 0: // auto
default:
mCompatibilityLocked = PR_FALSE;
break;
}
}
else {
mCompatibilityLocked = PR_FALSE; // auto
}
if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) { if (NS_SUCCEEDED(mPrefs->GetIntPref("nglayout.widget.mode", &prefInt))) {
mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast mWidgetRenderingMode = (enum nsWidgetRendering)prefInt; // bad cast
} }
@ -783,18 +761,15 @@ nsPresContext::GetCompatibilityMode(nsCompatibility* aResult)
NS_IMETHODIMP NS_IMETHODIMP
nsPresContext::SetCompatibilityMode(nsCompatibility aMode) nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
{ {
if (! mCompatibilityLocked) { mCompatibilityMode = aMode;
mCompatibilityMode = aMode;
} NS_ENSURE_TRUE(mShell, NS_OK);
// enable/disable the QuirkSheet // enable/disable the QuirkSheet
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::SetCompatibilityMode"); nsCOMPtr<nsIStyleSet> set;
if (mShell) { mShell->GetStyleSet(getter_AddRefs(set));
nsCOMPtr<nsIStyleSet> set; if (set) {
nsresult rv = mShell->GetStyleSet(getter_AddRefs(set)); set->EnableQuirkStyleSheet(mCompatibilityMode != eCompatibility_Standard);
if (NS_SUCCEEDED(rv) && set) {
set->EnableQuirkStyleSheet((mCompatibilityMode != eCompatibility_Standard) ? PR_TRUE : PR_FALSE);
}
} }
return NS_OK; return NS_OK;
} }
@ -1477,6 +1452,8 @@ nsPresContext::LoadImage(const nsString& aURL,
rv = content->GetDocument(*getter_AddRefs(document)); rv = content->GetDocument(*getter_AddRefs(document));
// If there is no document, skip the policy check // If there is no document, skip the policy check
// XXXldb This really means the document is being destroyed, so
// perhaps we're better off skipping the load entirely.
if (document) { if (document) {
nsCOMPtr<nsIScriptGlobalObject> globalScript; nsCOMPtr<nsIScriptGlobalObject> globalScript;
rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript));

Просмотреть файл

@ -262,7 +262,6 @@ protected:
nsCOMPtr<nsIURI> mBaseURL; nsCOMPtr<nsIURI> mBaseURL;
nsCompatibility mCompatibilityMode; nsCompatibility mCompatibilityMode;
PRPackedBool mCompatibilityLocked;
nsWidgetRendering mWidgetRenderingMode; nsWidgetRendering mWidgetRenderingMode;
PRPackedBool mImageAnimationStopped; // image animation stopped PRPackedBool mImageAnimationStopped; // image animation stopped

Просмотреть файл

@ -1057,7 +1057,8 @@ public:
NS_IMETHOD Init(nsIDocument* aDocument, NS_IMETHOD Init(nsIDocument* aDocument,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet); nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode);
NS_IMETHOD Destroy(); NS_IMETHOD Destroy();
NS_IMETHOD AllocateFrame(size_t aSize, void** aResult); NS_IMETHOD AllocateFrame(size_t aSize, void** aResult);
@ -1678,7 +1679,8 @@ NS_IMETHODIMP
PresShell::Init(nsIDocument* aDocument, PresShell::Init(nsIDocument* aDocument,
nsIPresContext* aPresContext, nsIPresContext* aPresContext,
nsIViewManager* aViewManager, nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet) nsIStyleSet* aStyleSet,
PRBool aIsQuirksMode)
{ {
NS_PRECONDITION(nsnull != aDocument, "null ptr"); NS_PRECONDITION(nsnull != aDocument, "null ptr");
NS_PRECONDITION(nsnull != aPresContext, "null ptr"); NS_PRECONDITION(nsnull != aPresContext, "null ptr");
@ -1699,11 +1701,16 @@ PresShell::Init(nsIDocument* aDocument,
mViewManager->SetViewObserver(this); mViewManager->SetViewObserver(this);
// Bind the context to the presentation shell. // Bind the context to the presentation shell.
mPresContext = dont_QueryInterface(aPresContext); mPresContext = aPresContext;
aPresContext->SetShell(this); aPresContext->SetShell(this);
mStyleSet = aStyleSet; mStyleSet = aStyleSet;
// Set the compatibility mode after attaching the pres context and
// style set, but before creating any frames.
mPresContext->SetCompatibilityMode(aIsQuirksMode
? eCompatibility_NavQuirks : eCompatibility_Standard);
mHistoryState = nsnull; mHistoryState = nsnull;
nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull, nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull,

Просмотреть файл

@ -864,9 +864,23 @@ NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable)
} }
} }
} }
NS_ASSERTION(mQuirkStyleSheet, "no quirk stylesheet");
if (mQuirkStyleSheet) { if (mQuirkStyleSheet) {
#if defined(DEBUG_warren) || defined(DEBUG_attinasi) #if defined(DEBUG_warren) || defined(DEBUG_attinasi)
printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" ); printf( "%s Quirk StyleSheet\n", aEnable ? "Enabling" : "Disabling" );
#endif
#ifdef DEBUG
PRUint32 count = 0;
if (mAgentRuleProcessors)
mAgentRuleProcessors->Count(&count);
PRBool enabledNow;
mQuirkStyleSheet->GetEnabled(enabledNow);
NS_ASSERTION(count == 0 || aEnable == enabledNow,
"enabling/disabling quirk stylesheet too late");
#ifdef DEBUG_dbaron
if (count != 0 && aEnable == enabledNow)
printf("WARNING: We set the quirks mode too many times.\n"); // we do!
#endif
#endif #endif
mQuirkStyleSheet->SetEnabled(aEnable); mQuirkStyleSheet->SetEnabled(aEnable);
} }