- decouple xul iframes from the browser.frames.enabled preference, so that one can open mozilla if that preference is set to false bug 107911

- avoid mutating style inside frame constructor for noframes bug 240129, this fixes crashes like bug 281333 and  bug 266222
- ConstructFrame does not append children if it fails, thats good enough for tables, so don't care about foreign children if they fail, this prevents tables from going into panic mode. bug 283147
- a display: table-caption behaves like a block for other table frames created below. bug 281527
r/sr= bzbarsky
This commit is contained in:
bmlk%gmx.de 2005-03-03 18:04:38 +00:00
Родитель 20fcb245ac
Коммит 7c229a9e64
2 изменённых файлов: 60 добавлений и 68 удалений

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

@ -2731,6 +2731,7 @@ nsCSSFrameConstructor::GetPseudoColGroupFrame(nsTableCreator& aTableCre
created = PR_TRUE;
}
if (created || IS_TABLE_CELL(parentFrameType) || // cell parent
(nsLayoutAtoms::tableCaptionFrame == parentFrameType) || // caption parent
!IsTableRelated(parentFrameType, PR_TRUE)) { // block parent
rv = CreatePseudoTableFrame(aTableCreator, aState, &aParentFrameIn);
}
@ -2771,6 +2772,7 @@ nsCSSFrameConstructor::GetPseudoRowGroupFrame(nsTableCreator& aTableCre
created = PR_TRUE;
}
if (created || IS_TABLE_CELL(parentFrameType) || // cell parent
(nsLayoutAtoms::tableCaptionFrame == parentFrameType) || // caption parent
!IsTableRelated(parentFrameType, PR_TRUE)) { // block parent
rv = CreatePseudoTableFrame(aTableCreator, aState, &aParentFrameIn);
}
@ -2804,6 +2806,7 @@ nsCSSFrameConstructor::GetPseudoRowFrame(nsTableCreator& aTableCreator,
if (!pseudoFrames.mLowestType) {
PRBool created = PR_FALSE;
if (IS_TABLE_CELL(parentFrameType) || // cell parent
(nsLayoutAtoms::tableCaptionFrame == parentFrameType) || // caption parent
!IsTableRelated(parentFrameType, PR_TRUE)) { // block parent
rv = CreatePseudoTableFrame(aTableCreator, aState, &aParentFrameIn);
created = PR_TRUE;
@ -2981,7 +2984,6 @@ IsSpecialHTMLContent(nsIContent* aContent)
tag == nsHTMLAtoms::legend ||
tag == nsHTMLAtoms::frameset ||
tag == nsHTMLAtoms::iframe ||
tag == nsHTMLAtoms::noframes ||
tag == nsHTMLAtoms::spacer ||
tag == nsHTMLAtoms::button ||
tag == nsHTMLAtoms::isindex;
@ -3603,7 +3605,8 @@ nsCSSFrameConstructor::ConstructTableForeignFrame(nsFrameConstructorState& aStat
nsFrameItems& childItems =
hasPseudoParent ? prevPseudoFrames.mCellInner.mChildList : aChildItems;
rv = ConstructFrame(aState, aContent, parentFrame, childItems);
ConstructFrame(aState, aContent, parentFrame, childItems);
// dont care about return value as ConstructFrame will not append a child if it fails.
// restore the pseudo frame state
aState.mPseudoFrames = prevPseudoFrames;
@ -5200,16 +5203,8 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState,
if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) {
ProcessPseudoFrames(aState, aFrameItems);
}
PRBool allowSubframes = PR_TRUE;
nsCOMPtr<nsISupports> container = aState.mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
docShell->GetAllowSubframes(&allowSubframes);
}
if (allowSubframes) {
rv = NS_NewHTMLFramesetFrame(mPresShell, &newFrame);
}
rv = NS_NewHTMLFramesetFrame(mPresShell, &newFrame);
}
else if (nsHTMLAtoms::iframe == aTag) {
if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) {
@ -5217,51 +5212,15 @@ nsCSSFrameConstructor::ConstructHTMLFrame(nsFrameConstructorState& aState,
}
isReplaced = PR_TRUE;
PRBool allowSubframes = PR_TRUE;
nsCOMPtr<nsISupports> container = aState.mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
docShell->GetAllowSubframes(&allowSubframes);
}
if (allowSubframes) {
rv = NS_NewSubDocumentFrame(mPresShell, &newFrame);
if (newFrame) {
// the nsSubDocumentFrame needs to know about its content parent during ::Init.
// there is no reasonable way to get the value there.
// so we store it as a frame property.
nsCOMPtr<nsIAtom> contentParentAtom = do_GetAtom("contentParent");
aState.mPresContext->PropertyTable()->
SetProperty(newFrame, contentParentAtom,
aParentFrame, nsnull, nsnull);
}
}
}
else if (nsHTMLAtoms::noframes == aTag) {
if (!aHasPseudoParent && !aState.mPseudoFrames.IsEmpty()) {
ProcessPseudoFrames(aState, aFrameItems);
}
isReplaced = PR_TRUE;
PRBool allowSubframes = PR_TRUE;
nsCOMPtr<nsISupports> container = aState.mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
docShell->GetAllowSubframes(&allowSubframes);
}
if (allowSubframes) {
// make <noframes> be display:none if frames are enabled
nsStyleDisplay* mutdisplay = (nsStyleDisplay*)aStyleContext->GetUniqueStyleData(eStyleStruct_Display);
mutdisplay->mDisplay = NS_STYLE_DISPLAY_NONE;
aState.mFrameManager->SetUndisplayedContent(aContent, aStyleContext);
}
else {
// XXXbz Use ConstructBlock, perhaps? Or simply bail out of here and
// allow it to be constructed by display? Would need to fix its display
// value accordingly... Really, we just need to fix bug 240129 and
// remove this code.
processChildren = PR_TRUE;
isFloatContainer = PR_TRUE;
rv = NS_NewBlockFrame(mPresShell, &newFrame);
rv = NS_NewSubDocumentFrame(mPresShell, &newFrame);
if (newFrame) {
// the nsSubDocumentFrame needs to know about its content parent during ::Init.
// there is no reasonable way to get the value there.
// so we store it as a frame property.
nsCOMPtr<nsIAtom> contentParentAtom = do_GetAtom("contentParent");
aState.mPresContext->PropertyTable()->
SetProperty(newFrame, contentParentAtom,
aParentFrame, nsnull, nsnull);
}
}
else if (nsHTMLAtoms::spacer == aTag) {
@ -5746,17 +5705,8 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState,
else if (aTag == nsXULAtoms::iframe || aTag == nsXULAtoms::editor ||
aTag == nsXULAtoms::browser) {
isReplaced = PR_TRUE;
// XXX should turning off frames allow XUL iframes?
PRBool allowSubframes = PR_TRUE;
nsCOMPtr<nsISupports> container = aState.mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
docShell->GetAllowSubframes(&allowSubframes);
}
if (allowSubframes) {
rv = NS_NewSubDocumentFrame(mPresShell, &newFrame);
}
rv = NS_NewSubDocumentFrame(mPresShell, &newFrame);
}
// PROGRESS METER CONSTRUCTION
else if (aTag == nsXULAtoms::progressmeter) {

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

@ -1378,6 +1378,8 @@ protected:
nsresult SetPrefLinkRules(void);
nsresult SetPrefFocusRules(void);
nsresult SetPrefNoScriptRule();
nsresult SetPrefNoFramesRule(void);
nsresult GetSelectionForCopy(nsISelection** outSelection);
@ -2202,6 +2204,9 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow)
if (NS_SUCCEEDED(result)) {
result = SetPrefNoScriptRule();
}
if (NS_SUCCEEDED(result)) {
result = SetPrefNoFramesRule();
}
}
#ifdef DEBUG_attinasi
printf( "Preference Style Rules set: error=%ld\n", (long)result);
@ -2368,6 +2373,43 @@ PresShell::SetPrefNoScriptRule()
return rv;
}
nsresult PresShell::SetPrefNoFramesRule(void)
{
NS_ASSERTION(mPresContext,"null prescontext not allowed");
if (!mPresContext) {
return NS_ERROR_FAILURE;
}
nsresult rv = NS_OK;
if (!mPrefStyleSheet) {
rv = CreatePreferenceStyleSheet();
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null");
// get the DOM interface to the stylesheet
nsCOMPtr<nsIDOMCSSStyleSheet> sheet(do_QueryInterface(mPrefStyleSheet, &rv));
NS_ENSURE_SUCCESS(rv, rv);
PRBool allowSubframes = PR_TRUE;
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
docShell->GetAllowSubframes(&allowSubframes);
}
if (!allowSubframes) {
PRUint32 index = 0;
rv = sheet->InsertRule(NS_LITERAL_STRING("noframes{display:block}"),
sInsertPrefSheetRulesAt, &index);
NS_ENSURE_SUCCESS(rv, rv);
rv = sheet->InsertRule(NS_LITERAL_STRING("frame, frameset, iframe {display:none!important}"),
sInsertPrefSheetRulesAt, &index);
}
return rv;
}
nsresult PresShell::SetPrefLinkRules(void)
{
NS_ASSERTION(mPresContext,"null prescontext not allowed");