Bug 475986. Make text-align:start work on <html:th> correctly. r+sr=dbaron

This commit is contained in:
Boris Zbarsky 2009-02-05 22:48:29 -05:00
parent d1cce1fe24
commit f47d90d8f4
24 changed files with 243 additions and 27 deletions

View File

@ -585,15 +585,18 @@
//
// Note: make sure the numbers are less than the numbers that start
// the vertical_align values below!
#define NS_STYLE_TEXT_ALIGN_DEFAULT 0
#define NS_STYLE_TEXT_ALIGN_LEFT 1
#define NS_STYLE_TEXT_ALIGN_RIGHT 2
#define NS_STYLE_TEXT_ALIGN_CENTER 3
#define NS_STYLE_TEXT_ALIGN_JUSTIFY 4
#define NS_STYLE_TEXT_ALIGN_CHAR 5 //align based on a certain character, for table cell
#define NS_STYLE_TEXT_ALIGN_MOZ_CENTER 6
#define NS_STYLE_TEXT_ALIGN_MOZ_RIGHT 7
#define NS_STYLE_TEXT_ALIGN_MOZ_LEFT 8
#define NS_STYLE_TEXT_ALIGN_DEFAULT 0
#define NS_STYLE_TEXT_ALIGN_LEFT 1
#define NS_STYLE_TEXT_ALIGN_RIGHT 2
#define NS_STYLE_TEXT_ALIGN_CENTER 3
#define NS_STYLE_TEXT_ALIGN_JUSTIFY 4
#define NS_STYLE_TEXT_ALIGN_CHAR 5 //align based on a certain character, for table cell
#define NS_STYLE_TEXT_ALIGN_MOZ_CENTER 6
#define NS_STYLE_TEXT_ALIGN_MOZ_RIGHT 7
#define NS_STYLE_TEXT_ALIGN_MOZ_LEFT 8
// NS_STYLE_TEXT_ALIGN_MOZ_CENTER_OR_INHERIT is only used in data structs; it
// is never present in stylesheets or computed data.
#define NS_STYLE_TEXT_ALIGN_MOZ_CENTER_OR_INHERIT 9
// See nsStyleText, nsStyleFont
#define NS_STYLE_TEXT_DECORATION_NONE 0

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr><th style="text-align: left">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="left"><th>Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="left" dir="rtl"><th>Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="left"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="right"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="center"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr><th style="text-align: right">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="right"><th>Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="right" dir="rtl"><th>Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr dir="rtl"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr dir="rtl" align="left"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr dir="rtl" align="right"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr dir="rtl" align="center"><th style="text-align: start">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr><th style="text-align: center">Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="center"><th>Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<body>
<table width="100%">
<tr align="center" dir="rtl"><th>Text</th></tr>
</table>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
th {
word-spacing: 0;
letter-spacing: 0;
text-transform: none;
text-indent: 0;
text-shadow: none;
line-height: normal;
white-space: normal;
word-wrap: normal;
}
</style>
</head>
<table width="100%">
<tr>
<th style="text-align: right">Text</th>
</tr>
</table>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
th {
word-spacing: 0;
letter-spacing: 0;
text-transform: none;
text-indent: 0;
text-shadow: none;
line-height: normal;
white-space: normal;
word-wrap: normal;
}
</style>
</head>
<table width="100%">
<tr style="text-align: right">
<th>Text</th>
</tr>
</table>
</html>

View File

@ -1040,6 +1040,24 @@ fails == 461512-1.html 461512-1-ref.html # Bug 461512
== 474336-1.xul 474336-1-ref.xul
== 474417-1.html 474417-1-ref.html
== 474472-1.html 474472-1-ref.html
== 475986-1a.html 475986-1-ref.html
== 475986-1b.html 475986-1-ref.html
== 475986-1c.html 475986-1-ref.html
== 475986-1d.html 475986-1-ref.html
== 475986-1e.html 475986-1-ref.html
== 475986-1f.html 475986-1-ref.html
== 475986-2a.html 475986-2-ref.html
== 475986-2b.html 475986-2-ref.html
== 475986-2c.html 475986-2-ref.html
== 475986-2d.html 475986-2-ref.html
== 475986-2e.html 475986-2-ref.html
== 475986-2f.html 475986-2-ref.html
== 475986-3a.html 475986-3-ref.html
== 475986-3b.html 475986-3-ref.html
== 475986-4.html 475986-4-ref.html
!= 475986-1-ref.html 475986-2-ref.html
!= 475986-1-ref.html 475986-3-ref.html
!= 475986-2-ref.html 475986-3-ref.html
== 476063-1.html 476063-1-ref.html
== 476063-2.html 476063-2-ref.html
!= 476063-3.html 476063-3-ref.html

View File

@ -109,27 +109,15 @@ nsHTMLStyleSheet::GenericTableRule::List(FILE* out, PRInt32 aIndent) const
}
#endif
static void PostResolveCallback(void* aStyleStruct, nsRuleData* aRuleData)
{
nsStyleText* text = (nsStyleText*)aStyleStruct;
if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_DEFAULT) {
nsStyleContext* parentContext = aRuleData->mStyleContext->GetParent();
if (parentContext) {
const nsStyleText* parentStyleText = parentContext->GetStyleText();
PRUint8 parentAlign = parentStyleText->mTextAlign;
text->mTextAlign = (NS_STYLE_TEXT_ALIGN_DEFAULT == parentAlign)
? NS_STYLE_TEXT_ALIGN_CENTER : parentAlign;
}
}
}
NS_IMETHODIMP
nsHTMLStyleSheet::TableTHRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData->mSIDs & NS_STYLE_INHERIT_BIT(Text)) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &PostResolveCallback;
if (aRuleData->mTextData->mTextAlign.GetUnit() == eCSSUnit_Null) {
aRuleData->mTextData->mTextAlign.
SetIntValue(NS_STYLE_TEXT_ALIGN_MOZ_CENTER_OR_INHERIT,
eCSSUnit_Enumerated);
}
}
return NS_OK;
}

View File

@ -970,6 +970,26 @@ CheckColorCallback(const nsRuleDataStruct& aData,
return aResult;
}
static nsRuleNode::RuleDetail
CheckTextCallback(const nsRuleDataStruct& aData,
nsRuleNode::RuleDetail aResult)
{
const nsRuleDataText& textData =
static_cast<const nsRuleDataText&>(aData);
if (textData.mTextAlign.GetUnit() == eCSSUnit_Enumerated &&
textData.mTextAlign.GetIntValue() ==
NS_STYLE_TEXT_ALIGN_MOZ_CENTER_OR_INHERIT) {
// Promote reset to mixed since we have something that depends on
// the parent.
if (aResult == nsRuleNode::eRulePartialReset)
aResult = nsRuleNode::eRulePartialMixed;
else if (aResult == nsRuleNode::eRuleFullReset)
aResult = nsRuleNode::eRuleFullMixed;
}
return aResult;
}
// for nsCSSPropList.h, so we get information on things in the style
// structs but not nsCSS*
@ -3059,6 +3079,13 @@ nsRuleNode::ComputeTextData(void* aStartStruct,
// text-align: enum, string, inherit, initial
if (eCSSUnit_String == textData.mTextAlign.GetUnit()) {
NS_NOTYETIMPLEMENTED("align string");
} else if (eCSSUnit_Enumerated == textData.mTextAlign.GetUnit() &&
NS_STYLE_TEXT_ALIGN_MOZ_CENTER_OR_INHERIT ==
textData.mTextAlign.GetIntValue()) {
canStoreInRuleTree = PR_FALSE;
PRUint8 parentAlign = parentText->mTextAlign;
text->mTextAlign = (NS_STYLE_TEXT_ALIGN_DEFAULT == parentAlign) ?
NS_STYLE_TEXT_ALIGN_CENTER : parentAlign;
} else
SetDiscrete(textData.mTextAlign, text->mTextAlign, canStoreInRuleTree,
SETDSC_ENUMERATED, parentText->mTextAlign,

View File

@ -86,7 +86,7 @@ STYLE_STRUCT_INHERITED(List, nsnull, ())
STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 4) {)
STYLE_STRUCT_RESET(Position, nsnull, ())
STYLE_STRUCT_TEST_CODE( } else {)
STYLE_STRUCT_INHERITED(Text, nsnull, ())
STYLE_STRUCT_INHERITED(Text, CheckTextCallback, ())
STYLE_STRUCT_TEST_CODE( })
STYLE_STRUCT_TEST_CODE( } else {)
STYLE_STRUCT_TEST_CODE( if (STYLE_STRUCT_TEST == 6) {)