From 5c317da98a22b07ec01e59635a6e77addda8599e Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Thu, 27 Jul 2000 23:37:44 +0000 Subject: [PATCH] Fix the way HTML's align attribute works for horizontal alignment of blocks. Use the -moz-center and -moz-right even in strict mode, and apply them to blocks in addition to tables. r=attinasi b=37083, 40038 git-svn-id: svn://10.0.0.236/trunk@74966 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsStyleContext.cpp | 14 +++++ .../html/content/src/nsGenericHTMLElement.cpp | 35 +++++------- .../layout/base/public/nsHTMLReflowState.h | 2 + mozilla/layout/base/src/nsStyleContext.cpp | 14 +++++ .../layout/generic/nsBlockReflowContext.cpp | 57 +++++++------------ mozilla/layout/generic/nsHTMLReflowState.cpp | 12 ++++ mozilla/layout/generic/nsHTMLReflowState.h | 2 + .../html/base/src/nsBlockReflowContext.cpp | 57 +++++++------------ .../html/base/src/nsHTMLReflowState.cpp | 12 ++++ .../html/content/src/nsGenericHTMLElement.cpp | 35 +++++------- mozilla/layout/style/nsStyleContext.cpp | 14 +++++ 11 files changed, 140 insertions(+), 114 deletions(-) diff --git a/mozilla/content/base/src/nsStyleContext.cpp b/mozilla/content/base/src/nsStyleContext.cpp index ee0eb35b35d..28b6140ad63 100644 --- a/mozilla/content/base/src/nsStyleContext.cpp +++ b/mozilla/content/base/src/nsStyleContext.cpp @@ -2837,6 +2837,20 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext, PRBool aRecurse) } mParent = holdParent; } + } else { + // In strict mode, we still have to support one "quirky" thing + // for tables. HTML's alignment attributes have always worked + // so they don't inherit into tables, but instead align the + // tables. We should keep doing this, because HTML alignment + // is just weird, and we shouldn't force it to match CSS. + if (GETSCDATA(Display).mDisplay == NS_STYLE_DISPLAY_TABLE) { + // -moz-center and -moz-right are used for HTML's alignment + if ((GETSCDATA(Text).mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) || + (GETSCDATA(Text).mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) + { + GETSCDATA(Text).mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT; + } + } } RecalcAutomaticData(aPresContext); diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index b84e2d4b7ea..bf412e089e2 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -2425,7 +2425,7 @@ static nsGenericHTMLElement::EnumTable kAlignTable[] = { { 0 } }; -static nsGenericHTMLElement::EnumTable kCompatDivAlignTable[] = { +static nsGenericHTMLElement::EnumTable kDivAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, @@ -2434,15 +2434,6 @@ static nsGenericHTMLElement::EnumTable kCompatDivAlignTable[] = { { 0 } }; -static nsGenericHTMLElement::EnumTable kDivAlignTable[] = { - { "left", NS_STYLE_TEXT_ALIGN_LEFT }, - { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, - { "center", NS_STYLE_TEXT_ALIGN_CENTER }, - { "middle", NS_STYLE_TEXT_ALIGN_CENTER }, - { "justify", NS_STYLE_TEXT_ALIGN_JUSTIFY }, - { 0 } -}; - static nsGenericHTMLElement::EnumTable kFrameborderQuirksTable[] = { { "yes", NS_STYLE_FRAME_YES }, { "no", NS_STYLE_FRAME_NO }, @@ -2550,12 +2541,18 @@ nsGenericHTMLElement::TableHAlignValueToString(const nsHTMLValue& aValue, //---------------------------------------- -// This table is used for TD,TH,TR, etc (but not TABLE) when in -// compatability mode +// These tables are used for TD,TH,TR, etc (but not TABLE) +static nsGenericHTMLElement::EnumTable kTableCellHAlignTable[] = { + { "left", NS_STYLE_TEXT_ALIGN_LEFT }, + { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, + { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, + { "char", NS_STYLE_TEXT_ALIGN_CHAR }, + { "justify",NS_STYLE_TEXT_ALIGN_JUSTIFY }, + { 0 } +}; + static nsGenericHTMLElement::EnumTable kCompatTableCellHAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, - // Note: use compatible version of alignment constants so that - // nested tables will be right aligned or center aligned. { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, { "char", NS_STYLE_TEXT_ALIGN_CHAR }, @@ -2578,7 +2575,7 @@ nsGenericHTMLElement::ParseTableCellHAlignValue(const nsString& aString, if (InNavQuirksMode(mDocument)) { return ParseEnumValue(aString, kCompatTableCellHAlignTable, aResult); } - return ParseEnumValue(aString, kTableHAlignTable, aResult); + return ParseEnumValue(aString, kTableCellHAlignTable, aResult); } PRBool @@ -2588,7 +2585,7 @@ nsGenericHTMLElement::TableCellHAlignValueToString(const nsHTMLValue& aValue, if (InNavQuirksMode(mDocument)) { return EnumValueToString(aValue, kCompatTableCellHAlignTable, aResult); } - return EnumValueToString(aValue, kTableHAlignTable, aResult); + return EnumValueToString(aValue, kTableCellHAlignTable, aResult); } //---------------------------------------- @@ -2618,9 +2615,6 @@ PRBool nsGenericHTMLElement::ParseDivAlignValue(const nsString& aString, nsHTMLValue& aResult) const { - if (InNavQuirksMode(mDocument)) { - return ParseEnumValue(aString, kCompatDivAlignTable, aResult); - } return ParseEnumValue(aString, kDivAlignTable, aResult); } @@ -2628,9 +2622,6 @@ PRBool nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue, nsString& aResult) const { - if (InNavQuirksMode(mDocument)) { - return EnumValueToString(aValue, kCompatDivAlignTable, aResult); - } return EnumValueToString(aValue, kDivAlignTable, aResult); } diff --git a/mozilla/layout/base/public/nsHTMLReflowState.h b/mozilla/layout/base/public/nsHTMLReflowState.h index 4fce25dc16f..87fed2cdbf6 100644 --- a/mozilla/layout/base/public/nsHTMLReflowState.h +++ b/mozilla/layout/base/public/nsHTMLReflowState.h @@ -34,6 +34,7 @@ class nsLineLayout; struct nsStyleDisplay; struct nsStylePosition; struct nsStyleSpacing; +struct nsStyleText; struct nsHypotheticalBox; /** @@ -206,6 +207,7 @@ struct nsHTMLReflowState { const nsStyleDisplay* mStyleDisplay; const nsStylePosition* mStylePosition; const nsStyleSpacing* mStyleSpacing; + const nsStyleText* mStyleText; // This value keeps track of how deeply nested a given reflow state // is from the top of the frame tree. diff --git a/mozilla/layout/base/src/nsStyleContext.cpp b/mozilla/layout/base/src/nsStyleContext.cpp index ee0eb35b35d..28b6140ad63 100644 --- a/mozilla/layout/base/src/nsStyleContext.cpp +++ b/mozilla/layout/base/src/nsStyleContext.cpp @@ -2837,6 +2837,20 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext, PRBool aRecurse) } mParent = holdParent; } + } else { + // In strict mode, we still have to support one "quirky" thing + // for tables. HTML's alignment attributes have always worked + // so they don't inherit into tables, but instead align the + // tables. We should keep doing this, because HTML alignment + // is just weird, and we shouldn't force it to match CSS. + if (GETSCDATA(Display).mDisplay == NS_STYLE_DISPLAY_TABLE) { + // -moz-center and -moz-right are used for HTML's alignment + if ((GETSCDATA(Text).mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) || + (GETSCDATA(Text).mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) + { + GETSCDATA(Text).mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT; + } + } } RecalcAutomaticData(aPresContext); diff --git a/mozilla/layout/generic/nsBlockReflowContext.cpp b/mozilla/layout/generic/nsBlockReflowContext.cpp index 5fd8d66c6b6..0e9f386b9b1 100644 --- a/mozilla/layout/generic/nsBlockReflowContext.cpp +++ b/mozilla/layout/generic/nsBlockReflowContext.cpp @@ -185,39 +185,26 @@ nsBlockReflowContext::AlignBlockHorizontally(nscoord aWidth, } else if (eStyleUnit_Auto != rightUnit) { // The block/table doesn't have auto margins. - PRBool doCSS = PR_TRUE; - if (mIsTable) { - const nsStyleText* styleText; - mOuterReflowState.frame->GetStyleData(eStyleStruct_Text, - (const nsStyleStruct*&)styleText); - // This is a navigator compatability case: tables are - // affected by the text alignment of the containing - // block. CSS doesn't do this, so we use special - // text-align attribute values to signal these - // compatability cases. - switch (styleText->mTextAlign) { - case NS_STYLE_TEXT_ALIGN_MOZ_RIGHT: - case NS_STYLE_TEXT_ALIGN_RIGHT: - aAlign.mXOffset += remainingSpace; - doCSS = PR_FALSE; - break; - case NS_STYLE_TEXT_ALIGN_MOZ_CENTER: - case NS_STYLE_TEXT_ALIGN_CENTER: - { - nsCompatibility mode; - mPresContext->GetCompatibilityMode(&mode); - if (eCompatibility_NavQuirks == mode) { - aAlign.mXOffset += remainingSpace / 2; - doCSS = PR_FALSE; - } - } - break; - } - } - if (doCSS) { -// XXX It's not clear we can ever get here because for normal blocks, -// their size will be well defined by the nsHTMLReflowState logic -// (maybe width=0 cases get here?) + + // For normal (non-table) blocks we don't get here because + // nsHTMLReflowState::CalculateBlockSideMargins handles this. + // (I think there may be an exception to that, though...) + + // We use a special value of the text-align property for + // HTML alignment (the CENTER element and DIV ALIGN=...) + // since it acts on blocks and tables rather than just + // being a text-align. + // So, check the text-align value from the parent to see if + // it has one of these special values. + const nsStyleText* styleText = mOuterReflowState.mStyleText; + if (styleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT) { + aAlign.mXOffset += remainingSpace; + } else if (styleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) { + aAlign.mXOffset += remainingSpace / 2; + } else { + // If we don't have a special text-align value indicating + // HTML alignment, then use the CSS rules. + // When neither margin is auto then the block is said to // be over constrained, Depending on the direction, choose // which margin to treat as auto. @@ -226,9 +213,9 @@ nsBlockReflowContext::AlignBlockHorizontally(nscoord aWidth, // The left margin becomes auto aAlign.mXOffset += remainingSpace; } - else { + //else { // The right margin becomes auto which is a no-op - } + //} } } } diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 74bf9a0c5c2..ba6d2daa401 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -178,6 +178,8 @@ nsHTMLReflowState::Init(nsIPresContext* aPresContext, (const nsStyleStruct*&)mStyleDisplay); frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)mStyleSpacing); + frame->GetStyleData(eStyleStruct_Text, + (const nsStyleStruct*&)mStyleText); mFrameType = DetermineFrameType(frame, mStylePosition, mStyleDisplay); InitConstraints(aPresContext, aContainingBlockWidth, aContainingBlockHeight); } @@ -2001,6 +2003,16 @@ nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth, const nsHTMLReflowState* prs = (const nsHTMLReflowState*) parentReflowState; if (prs) { + + // First check if there is an HTML alignment that we should honor + if ((prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) || + (prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) + { + isAutoLeftMargin = PR_TRUE; + isAutoRightMargin = + (prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER); + } else + // Otherwise apply the CSS rules if (NS_STYLE_DIRECTION_LTR == prs->mStyleDisplay->mDirection) { // The specified value of margin-right is ignored (== forced // to auto) diff --git a/mozilla/layout/generic/nsHTMLReflowState.h b/mozilla/layout/generic/nsHTMLReflowState.h index 4fce25dc16f..87fed2cdbf6 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.h +++ b/mozilla/layout/generic/nsHTMLReflowState.h @@ -34,6 +34,7 @@ class nsLineLayout; struct nsStyleDisplay; struct nsStylePosition; struct nsStyleSpacing; +struct nsStyleText; struct nsHypotheticalBox; /** @@ -206,6 +207,7 @@ struct nsHTMLReflowState { const nsStyleDisplay* mStyleDisplay; const nsStylePosition* mStylePosition; const nsStyleSpacing* mStyleSpacing; + const nsStyleText* mStyleText; // This value keeps track of how deeply nested a given reflow state // is from the top of the frame tree. diff --git a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp index 5fd8d66c6b6..0e9f386b9b1 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowContext.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowContext.cpp @@ -185,39 +185,26 @@ nsBlockReflowContext::AlignBlockHorizontally(nscoord aWidth, } else if (eStyleUnit_Auto != rightUnit) { // The block/table doesn't have auto margins. - PRBool doCSS = PR_TRUE; - if (mIsTable) { - const nsStyleText* styleText; - mOuterReflowState.frame->GetStyleData(eStyleStruct_Text, - (const nsStyleStruct*&)styleText); - // This is a navigator compatability case: tables are - // affected by the text alignment of the containing - // block. CSS doesn't do this, so we use special - // text-align attribute values to signal these - // compatability cases. - switch (styleText->mTextAlign) { - case NS_STYLE_TEXT_ALIGN_MOZ_RIGHT: - case NS_STYLE_TEXT_ALIGN_RIGHT: - aAlign.mXOffset += remainingSpace; - doCSS = PR_FALSE; - break; - case NS_STYLE_TEXT_ALIGN_MOZ_CENTER: - case NS_STYLE_TEXT_ALIGN_CENTER: - { - nsCompatibility mode; - mPresContext->GetCompatibilityMode(&mode); - if (eCompatibility_NavQuirks == mode) { - aAlign.mXOffset += remainingSpace / 2; - doCSS = PR_FALSE; - } - } - break; - } - } - if (doCSS) { -// XXX It's not clear we can ever get here because for normal blocks, -// their size will be well defined by the nsHTMLReflowState logic -// (maybe width=0 cases get here?) + + // For normal (non-table) blocks we don't get here because + // nsHTMLReflowState::CalculateBlockSideMargins handles this. + // (I think there may be an exception to that, though...) + + // We use a special value of the text-align property for + // HTML alignment (the CENTER element and DIV ALIGN=...) + // since it acts on blocks and tables rather than just + // being a text-align. + // So, check the text-align value from the parent to see if + // it has one of these special values. + const nsStyleText* styleText = mOuterReflowState.mStyleText; + if (styleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT) { + aAlign.mXOffset += remainingSpace; + } else if (styleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) { + aAlign.mXOffset += remainingSpace / 2; + } else { + // If we don't have a special text-align value indicating + // HTML alignment, then use the CSS rules. + // When neither margin is auto then the block is said to // be over constrained, Depending on the direction, choose // which margin to treat as auto. @@ -226,9 +213,9 @@ nsBlockReflowContext::AlignBlockHorizontally(nscoord aWidth, // The left margin becomes auto aAlign.mXOffset += remainingSpace; } - else { + //else { // The right margin becomes auto which is a no-op - } + //} } } } diff --git a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp index 74bf9a0c5c2..ba6d2daa401 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowState.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowState.cpp @@ -178,6 +178,8 @@ nsHTMLReflowState::Init(nsIPresContext* aPresContext, (const nsStyleStruct*&)mStyleDisplay); frame->GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct*&)mStyleSpacing); + frame->GetStyleData(eStyleStruct_Text, + (const nsStyleStruct*&)mStyleText); mFrameType = DetermineFrameType(frame, mStylePosition, mStyleDisplay); InitConstraints(aPresContext, aContainingBlockWidth, aContainingBlockHeight); } @@ -2001,6 +2003,16 @@ nsHTMLReflowState::CalculateBlockSideMargins(nscoord aAvailWidth, const nsHTMLReflowState* prs = (const nsHTMLReflowState*) parentReflowState; if (prs) { + + // First check if there is an HTML alignment that we should honor + if ((prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) || + (prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) + { + isAutoLeftMargin = PR_TRUE; + isAutoRightMargin = + (prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER); + } else + // Otherwise apply the CSS rules if (NS_STYLE_DIRECTION_LTR == prs->mStyleDisplay->mDirection) { // The specified value of margin-right is ignored (== forced // to auto) diff --git a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp index b84e2d4b7ea..bf412e089e2 100644 --- a/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/layout/html/content/src/nsGenericHTMLElement.cpp @@ -2425,7 +2425,7 @@ static nsGenericHTMLElement::EnumTable kAlignTable[] = { { 0 } }; -static nsGenericHTMLElement::EnumTable kCompatDivAlignTable[] = { +static nsGenericHTMLElement::EnumTable kDivAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, @@ -2434,15 +2434,6 @@ static nsGenericHTMLElement::EnumTable kCompatDivAlignTable[] = { { 0 } }; -static nsGenericHTMLElement::EnumTable kDivAlignTable[] = { - { "left", NS_STYLE_TEXT_ALIGN_LEFT }, - { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, - { "center", NS_STYLE_TEXT_ALIGN_CENTER }, - { "middle", NS_STYLE_TEXT_ALIGN_CENTER }, - { "justify", NS_STYLE_TEXT_ALIGN_JUSTIFY }, - { 0 } -}; - static nsGenericHTMLElement::EnumTable kFrameborderQuirksTable[] = { { "yes", NS_STYLE_FRAME_YES }, { "no", NS_STYLE_FRAME_NO }, @@ -2550,12 +2541,18 @@ nsGenericHTMLElement::TableHAlignValueToString(const nsHTMLValue& aValue, //---------------------------------------- -// This table is used for TD,TH,TR, etc (but not TABLE) when in -// compatability mode +// These tables are used for TD,TH,TR, etc (but not TABLE) +static nsGenericHTMLElement::EnumTable kTableCellHAlignTable[] = { + { "left", NS_STYLE_TEXT_ALIGN_LEFT }, + { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, + { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, + { "char", NS_STYLE_TEXT_ALIGN_CHAR }, + { "justify",NS_STYLE_TEXT_ALIGN_JUSTIFY }, + { 0 } +}; + static nsGenericHTMLElement::EnumTable kCompatTableCellHAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, - // Note: use compatible version of alignment constants so that - // nested tables will be right aligned or center aligned. { "right", NS_STYLE_TEXT_ALIGN_MOZ_RIGHT }, { "center", NS_STYLE_TEXT_ALIGN_MOZ_CENTER }, { "char", NS_STYLE_TEXT_ALIGN_CHAR }, @@ -2578,7 +2575,7 @@ nsGenericHTMLElement::ParseTableCellHAlignValue(const nsString& aString, if (InNavQuirksMode(mDocument)) { return ParseEnumValue(aString, kCompatTableCellHAlignTable, aResult); } - return ParseEnumValue(aString, kTableHAlignTable, aResult); + return ParseEnumValue(aString, kTableCellHAlignTable, aResult); } PRBool @@ -2588,7 +2585,7 @@ nsGenericHTMLElement::TableCellHAlignValueToString(const nsHTMLValue& aValue, if (InNavQuirksMode(mDocument)) { return EnumValueToString(aValue, kCompatTableCellHAlignTable, aResult); } - return EnumValueToString(aValue, kTableHAlignTable, aResult); + return EnumValueToString(aValue, kTableCellHAlignTable, aResult); } //---------------------------------------- @@ -2618,9 +2615,6 @@ PRBool nsGenericHTMLElement::ParseDivAlignValue(const nsString& aString, nsHTMLValue& aResult) const { - if (InNavQuirksMode(mDocument)) { - return ParseEnumValue(aString, kCompatDivAlignTable, aResult); - } return ParseEnumValue(aString, kDivAlignTable, aResult); } @@ -2628,9 +2622,6 @@ PRBool nsGenericHTMLElement::DivAlignValueToString(const nsHTMLValue& aValue, nsString& aResult) const { - if (InNavQuirksMode(mDocument)) { - return EnumValueToString(aValue, kCompatDivAlignTable, aResult); - } return EnumValueToString(aValue, kDivAlignTable, aResult); } diff --git a/mozilla/layout/style/nsStyleContext.cpp b/mozilla/layout/style/nsStyleContext.cpp index ee0eb35b35d..28b6140ad63 100644 --- a/mozilla/layout/style/nsStyleContext.cpp +++ b/mozilla/layout/style/nsStyleContext.cpp @@ -2837,6 +2837,20 @@ StyleContextImpl::RemapStyle(nsIPresContext* aPresContext, PRBool aRecurse) } mParent = holdParent; } + } else { + // In strict mode, we still have to support one "quirky" thing + // for tables. HTML's alignment attributes have always worked + // so they don't inherit into tables, but instead align the + // tables. We should keep doing this, because HTML alignment + // is just weird, and we shouldn't force it to match CSS. + if (GETSCDATA(Display).mDisplay == NS_STYLE_DISPLAY_TABLE) { + // -moz-center and -moz-right are used for HTML's alignment + if ((GETSCDATA(Text).mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER) || + (GETSCDATA(Text).mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) + { + GETSCDATA(Text).mTextAlign = NS_STYLE_TEXT_ALIGN_DEFAULT; + } + } } RecalcAutomaticData(aPresContext);