From f3af1a7aef72072a93471b1bc702aca573d5919e Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Thu, 22 Jan 2004 21:34:04 +0000 Subject: [PATCH] Fix two problems with display fixups. b=231787 r+sr=bzbarsky --- content/base/src/nsRuleNode.cpp | 29 ++++++++++--------- layout/base/nsCSSFrameConstructor.cpp | 6 ++-- .../html/style/src/nsCSSFrameConstructor.cpp | 6 ++-- layout/style/nsRuleNode.cpp | 29 ++++++++++--------- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/content/base/src/nsRuleNode.cpp b/content/base/src/nsRuleNode.cpp index 1239a8eddfa4..c26daf94c1f8 100644 --- a/content/base/src/nsRuleNode.cpp +++ b/content/base/src/nsRuleNode.cpp @@ -2585,19 +2585,6 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, } } - if (inherited) - // We inherited, and therefore can't be cached in the rule node. We have to be put right on the - // style context. - aContext->SetStyle(eStyleStruct_Display, display); - else { - // We were fully specified and can therefore be cached right on the rule node. - if (!aHighestNode->mStyleData.mResetData) - aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData; - aHighestNode->mStyleData.mResetData->mDisplayData = display; - // Propagate the bit down. - PropagateDependentBit(NS_STYLE_INHERIT_BIT(Display), aHighestNode); - } - // CSS2 specified fixups: if (generatedContent) { // According to CSS2 section 12.1, :before and :after @@ -2613,6 +2600,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, PRUint8 displayValue = display->mDisplay; if (displayValue != NS_STYLE_DISPLAY_NONE && displayValue != NS_STYLE_DISPLAY_INLINE) { + inherited = PR_TRUE; if (parentDisplay->IsBlockLevel()) { // If the subject of the selector is a block-level element, // allowed values are 'none', 'inline', 'block', and 'marker'. @@ -2629,7 +2617,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, display->mDisplay = NS_STYLE_DISPLAY_INLINE; } } - } + } else if (display->mDisplay != NS_STYLE_DISPLAY_NONE) { // CSS2 9.7 specifies display type corrections dealing with 'float' // and 'position'. Since generated content can't be floated or @@ -2662,6 +2650,19 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, } } + if (inherited) + // We inherited, and therefore can't be cached in the rule node. We have to be put right on the + // style context. + aContext->SetStyle(eStyleStruct_Display, display); + else { + // We were fully specified and can therefore be cached right on the rule node. + if (!aHighestNode->mStyleData.mResetData) + aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData; + aHighestNode->mStyleData.mResetData->mDisplayData = display; + // Propagate the bit down. + PropagateDependentBit(NS_STYLE_INHERIT_BIT(Display), aHighestNode); + } + return display; } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 7bbe3f9afc78..66dde53947c8 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3311,9 +3311,6 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, } } - PRBool docElemIsTable = IsTableRelated(display->mDisplay, PR_FALSE); - - // --------- IF SCROLLABLE WRAP IN SCROLLFRAME -------- PRBool isScrollable = IsScrollable(aPresContext, display); @@ -3348,6 +3345,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, PRBool isBlockFrame = PR_FALSE; nsresult rv; + PRBool docElemIsTable = display->mDisplay == NS_STYLE_DISPLAY_TABLE || + display->mDisplay == NS_STYLE_DISPLAY_INLINE_TABLE; + if (docElemIsTable) { // if the document is a table then just populate it. rv = ConstructDocElementTableFrame(aPresShell, aPresContext, aDocElement, diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 7bbe3f9afc78..66dde53947c8 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -3311,9 +3311,6 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, } } - PRBool docElemIsTable = IsTableRelated(display->mDisplay, PR_FALSE); - - // --------- IF SCROLLABLE WRAP IN SCROLLFRAME -------- PRBool isScrollable = IsScrollable(aPresContext, display); @@ -3348,6 +3345,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, PRBool isBlockFrame = PR_FALSE; nsresult rv; + PRBool docElemIsTable = display->mDisplay == NS_STYLE_DISPLAY_TABLE || + display->mDisplay == NS_STYLE_DISPLAY_INLINE_TABLE; + if (docElemIsTable) { // if the document is a table then just populate it. rv = ConstructDocElementTableFrame(aPresShell, aPresContext, aDocElement, diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 1239a8eddfa4..c26daf94c1f8 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -2585,19 +2585,6 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, } } - if (inherited) - // We inherited, and therefore can't be cached in the rule node. We have to be put right on the - // style context. - aContext->SetStyle(eStyleStruct_Display, display); - else { - // We were fully specified and can therefore be cached right on the rule node. - if (!aHighestNode->mStyleData.mResetData) - aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData; - aHighestNode->mStyleData.mResetData->mDisplayData = display; - // Propagate the bit down. - PropagateDependentBit(NS_STYLE_INHERIT_BIT(Display), aHighestNode); - } - // CSS2 specified fixups: if (generatedContent) { // According to CSS2 section 12.1, :before and :after @@ -2613,6 +2600,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, PRUint8 displayValue = display->mDisplay; if (displayValue != NS_STYLE_DISPLAY_NONE && displayValue != NS_STYLE_DISPLAY_INLINE) { + inherited = PR_TRUE; if (parentDisplay->IsBlockLevel()) { // If the subject of the selector is a block-level element, // allowed values are 'none', 'inline', 'block', and 'marker'. @@ -2629,7 +2617,7 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, display->mDisplay = NS_STYLE_DISPLAY_INLINE; } } - } + } else if (display->mDisplay != NS_STYLE_DISPLAY_NONE) { // CSS2 9.7 specifies display type corrections dealing with 'float' // and 'position'. Since generated content can't be floated or @@ -2662,6 +2650,19 @@ nsRuleNode::ComputeDisplayData(nsStyleStruct* aStartStruct, } } + if (inherited) + // We inherited, and therefore can't be cached in the rule node. We have to be put right on the + // style context. + aContext->SetStyle(eStyleStruct_Display, display); + else { + // We were fully specified and can therefore be cached right on the rule node. + if (!aHighestNode->mStyleData.mResetData) + aHighestNode->mStyleData.mResetData = new (mPresContext) nsResetStyleData; + aHighestNode->mStyleData.mResetData->mDisplayData = display; + // Propagate the bit down. + PropagateDependentBit(NS_STYLE_INHERIT_BIT(Display), aHighestNode); + } + return display; }