Bug 444688. Use an IsFrameOfType check instead of a frame state bit to detect whether a frame excludes ignorable whitespace children. r+sr=dbaronlayout

This commit is contained in:
Robert O'Callahan 2008-07-14 10:41:18 +12:00
parent 8901cc3a8a
commit 7e15def36c
20 changed files with 70 additions and 136 deletions

View File

@ -4084,11 +4084,8 @@ NeedFrameFor(nsIFrame* aParentFrame,
nsIContent* aChildContent)
{
// don't create a whitespace frame if aParentFrame doesn't want it
if ((NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE & aParentFrame->GetStateBits())
&& TextIsOnlyWhitespace(aChildContent)) {
return PR_FALSE;
}
return PR_TRUE;
return !aParentFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace) ||
!TextIsOnlyWhitespace(aChildContent);
}
const nsStyleDisplay*
@ -6863,7 +6860,6 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsFrameConstructorState& aState,
return NS_OK;
nsresult rv = NS_OK;
PRBool ignoreInterTagWhitespace = PR_TRUE;
NS_ASSERTION(aTag != nsnull, "null MathML tag");
if (aTag == nsnull)
@ -6941,10 +6937,8 @@ nsCSSFrameConstructor::ConstructMathMLFrame(nsFrameConstructorState& aState,
// If we succeeded in creating a frame then initialize it, process its
// children (if requested), and set the initial child list
if (newFrame) {
// record that children that are ignorable whitespace should be excluded
if (ignoreInterTagWhitespace) {
newFrame->AddStateBits(NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE);
}
NS_ASSERTION(newFrame->IsFrameOfType(nsIFrame::eExcludesIgnorableWhitespace),
"Ignorable whitespace should be excluded");
// Only <math> elements can be floated or positioned. All other MathML
// should be in-flow.

View File

@ -231,12 +231,7 @@ enum {
// results when an inline has been split because of a nested block.
NS_FRAME_IS_SPECIAL = 0x00008000,
// If this bit is set, the frame doesn't allow ignorable whitespace as
// children. For example, the whitespace between <table>\n<tr>\n<td>
// will be excluded during the construction of children.
// The bit is set when the frame is first created and remain
// unchanged during the life-time of the frame.
NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE = 0x00010000,
NS_FRAME_THIS_BIT_BELONGS_TO_ROC_DO_NOT_USE_OR_I_WILL_HUNT_YOU_DOWN = 0x00010000,
#ifdef IBMBIDI
// If this bit is set, the frame itself is a bidi continuation,
@ -1582,6 +1577,10 @@ public:
eXULBox = 1 << 7,
eCanContainOverflowContainers = 1 << 8,
eBlockFrame = 1 << 9,
// If this bit is set, the frame doesn't allow ignorable whitespace as
// children. For example, the whitespace between <table>\n<tr>\n<td>
// will be excluded during the construction of children.
eExcludesIgnorableWhitespace = 1 << 10,
// These are to allow nsFrame::Init to assert that IsFrameOfType
// implementations all call the base class method. They are only

View File

@ -111,7 +111,8 @@ public:
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return !(aFlags & nsIFrame::eLineParticipant) &&
nsHTMLContainerFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
nsHTMLContainerFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
virtual PRIntn GetSkipSides() const { return 0; }
@ -447,7 +448,8 @@ public:
}
virtual PRBool IsFrameOfType(PRUint32 aFlags) const {
return nsBlockFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsBlockFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
protected:
@ -517,7 +519,8 @@ public:
}
virtual PRBool IsFrameOfType(PRUint32 aFlags) const {
return nsInlineFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsInlineFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
protected:

View File

@ -846,19 +846,6 @@ nsMathMLmtdInnerFrame::~nsMathMLmtdInnerFrame()
{
}
NS_IMETHODIMP
nsMathMLmtdInnerFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
return rv;
}
NS_IMETHODIMP
nsMathMLmtdInnerFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -84,7 +84,8 @@ public:
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsTableOuterFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsTableOuterFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
protected:
@ -144,7 +145,8 @@ public:
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsTableFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsTableFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
// helper to restyle and reflow the table when a row is changed -- since MathML
@ -203,7 +205,8 @@ public:
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsTableRowFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsTableRowFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
// helper to restyle and reflow the table -- @see nsMathMLmtableFrame.
@ -241,7 +244,8 @@ public:
virtual PRInt32 GetColSpan();
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsTableCellFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
protected:
@ -271,13 +275,6 @@ public:
return NS_OK;
}
// overloaded nsBlockFrame methods
NS_IMETHOD
Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD
Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -286,7 +283,8 @@ public:
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsBlockFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
return nsBlockFrame::IsFrameOfType(aFlags &
~(nsIFrame::eMathML | nsIFrame::eExcludesIgnorableWhitespace));
}
protected:

View File

@ -172,20 +172,6 @@ NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
return new (aPresShell) nsTableColFrame(aContext);
}
NS_IMETHODIMP
nsTableColFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
// Let the base class do its initialization
nsresult rv = nsSplittableFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
return rv;
}
nsTableColFrame*
nsTableColFrame::GetNextCol() const
{

View File

@ -76,10 +76,6 @@ public:
nsTableColFrame* GetNextCol() const;
NS_IMETHOD Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -92,6 +88,12 @@ public:
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) { return NS_OK; }
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsSplittableFrame::IsFrameOfType(aFlags &
~(nsIFrame::eExcludesIgnorableWhitespace));
}
/**
* Get the "type" of the frame
*

View File

@ -489,22 +489,6 @@ NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
return new (aPresShell) nsTableColGroupFrame(aContext);
}
NS_IMETHODIMP
nsTableColGroupFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsresult rv;
// Let the base class do its processing
rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
return rv;
}
nsIAtom*
nsTableColGroupFrame::GetType() const
{

View File

@ -69,13 +69,6 @@ public:
*/
friend nsIFrame* NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
/** sets defaults for the colgroup.
* @see nsIFrame::Init
*/
NS_IMETHOD Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
/** Initialize the colgroup frame with a set of children.
* @see nsIFrame::SetInitialChildList
*/
@ -151,6 +144,12 @@ public:
nsTableFrame::ReflowColGroups */
virtual PRBool IsContainingBlock() const;
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsHTMLContainerFrame::IsFrameOfType(aFlags &
~nsIFrame::eExcludesIgnorableWhitespace);
}
/**
* Get the "type" of the frame
*

View File

@ -222,9 +222,6 @@ nsTableFrame::Init(nsIContent* aContent,
// Let the base class do its processing
rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
// see if border collapse is on, if so set it
const nsStyleTableBorder* tableStyle = GetStyleTableBorder();
PRBool borderCollapse = (NS_STYLE_BORDER_COLLAPSE == tableStyle->mBorderCollapse);

View File

@ -372,6 +372,12 @@ public:
nsIFrame** aProviderFrame,
PRBool* aIsChild);
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsHTMLContainerFrame::IsFrameOfType(aFlags &
~nsIFrame::eExcludesIgnorableWhitespace);
}
/**
* Get the "type" of the frame
*

View File

@ -220,20 +220,6 @@ nsTableOuterFrame::IsContainingBlock() const
return PR_FALSE;
}
NS_IMETHODIMP
nsTableOuterFrame::Init(
nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
return rv;
}
void
nsTableOuterFrame::Destroy()
{

View File

@ -99,12 +99,14 @@ public:
// nsIFrame overrides - see there for a description
NS_IMETHOD Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
virtual void Destroy();
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsHTMLContainerFrame::IsFrameOfType(aFlags &
~nsIFrame::eExcludesIgnorableWhitespace);
}
virtual PRBool IsContainingBlock() const;
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,

View File

@ -164,9 +164,6 @@ nsTableRowFrame::Init(nsIContent* aContent,
// Let the base class do its initialization
rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
if (aPrevInFlow) {
// Set the row index
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow;

View File

@ -118,6 +118,12 @@ public:
void DidResize();
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsHTMLContainerFrame::IsFrameOfType(aFlags &
~nsIFrame::eExcludesIgnorableWhitespace);
}
/**
* Get the "type" of the frame
*

View File

@ -1587,20 +1587,6 @@ NS_NewTableRowGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
return new (aPresShell) nsTableRowGroupFrame(aContext);
}
NS_IMETHODIMP
nsTableRowGroupFrame::Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow)
{
// Let the base class do its processing
nsresult rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
// record that children that are ignorable whitespace should be excluded
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
return rv;
}
#ifdef DEBUG
NS_IMETHODIMP
nsTableRowGroupFrame::GetFrameName(nsAString& aResult) const

View File

@ -109,10 +109,6 @@ public:
friend nsIFrame* NS_NewTableRowGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
virtual ~nsTableRowGroupFrame();
NS_IMETHOD Init(nsIContent* aContent,
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
@ -145,6 +141,12 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsHTMLContainerFrame::IsFrameOfType(aFlags &
~nsIFrame::eExcludesIgnorableWhitespace);
}
/**
* Get the "type" of the frame
*

View File

@ -200,13 +200,6 @@ nsBoxFrame::Init(nsIContent* aContent,
nsresult rv = nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
NS_ENSURE_SUCCESS(rv, rv);
// record that children that are ignorable whitespace should be excluded
// (When content was loaded via the XUL content sink, it's already
// been excluded, but we need this for when the XUL namespace is used
// in other MIME types or when the XUL CSS display types are used with
// non-XUL elements.)
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
MarkIntrinsicWidthsDirty();
// see if we need a widget

View File

@ -145,12 +145,19 @@ public:
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
// record that children that are ignorable whitespace should be excluded
// (When content was loaded via the XUL content sink, it's already
// been excluded, but we need this for when the XUL namespace is used
// in other MIME types or when the XUL CSS display types are used with
// non-XUL elements.)
// This is bogus, but it's what we've always done.
// (Given that we're replaced, we need to say we're a replaced element
// that contains a block so nsHTMLReflowState doesn't tell us to be
// NS_INTRINSICSIZE wide.)
return nsContainerFrame::IsFrameOfType(aFlags &
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox));
~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock | eXULBox |
nsIFrame::eExcludesIgnorableWhitespace));
}
#ifdef DEBUG

2
nsprpub/configure vendored
View File

@ -6097,7 +6097,7 @@ s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '`
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs