Fix col border drawing for cols that are explicitly in the source. Bug 350444,

r=bernd, sr=roc
This commit is contained in:
bzbarsky%mit.edu 2006-11-13 15:46:52 +00:00
Родитель dc1623668e
Коммит b1cb55508a
2 изменённых файлов: 49 добавлений и 2 удалений

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

@ -266,6 +266,17 @@ static void ColPostResolveCallback(nsStyleStruct* aStyleStruct, nsRuleData* aRul
NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
}
static void UngroupedColPostResolveCallback(nsStyleStruct* aStyleStruct,
nsRuleData* aRuleData)
{
// Pass PR_TRUE for aGroup, so that we find the table's style
// context correctly.
::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_LEFT, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_RIGHT, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
}
NS_IMETHODIMP
nsHTMLStyleSheet::TableColRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
@ -275,6 +286,16 @@ nsHTMLStyleSheet::TableColRule::MapRuleInfoInto(nsRuleData* aRuleData)
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLStyleSheet::TableUngroupedColRule::MapRuleInfoInto(nsRuleData* aRuleData)
{
if (aRuleData && aRuleData->mSID == eStyleStruct_Border) {
aRuleData->mCanStoreInRuleTree = PR_FALSE;
aRuleData->mPostResolveCallback = &UngroupedColPostResolveCallback;
}
return NS_OK;
}
// -----------------------------------------------------------
struct MappedAttrTableEntry : public PLDHashEntryHdr {
@ -359,6 +380,11 @@ nsHTMLStyleSheet::Init()
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mTableColRule);
mTableUngroupedColRule = new TableUngroupedColRule();
if (!mTableUngroupedColRule)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(mTableUngroupedColRule);
mTableTHRule = new TableTHRule();
if (!mTableTHRule)
return NS_ERROR_OUT_OF_MEMORY;
@ -378,6 +404,7 @@ nsHTMLStyleSheet::~nsHTMLStyleSheet()
NS_IF_RELEASE(mTableRowRule);
NS_IF_RELEASE(mTableColgroupRule);
NS_IF_RELEASE(mTableColRule);
NS_IF_RELEASE(mTableUngroupedColRule);
NS_IF_RELEASE(mTableTHRule);
if (mMappedAttrTable.ops)
@ -446,7 +473,13 @@ nsHTMLStyleSheet::RulesMatching(ElementRuleProcessorData* aData)
ruleWalker->Forward(mTableTbodyRule);
}
else if (tag == nsHTMLAtoms::col) {
ruleWalker->Forward(mTableColRule);
nsIContent* parent = aData->mParentContent;
if (parent && parent->IsNodeOfType(nsIContent::eHTML) &&
parent->Tag() == nsHTMLAtoms::colgroup) {
ruleWalker->Forward(mTableColRule);
} else {
ruleWalker->Forward(mTableUngroupedColRule);
}
}
else if (tag == nsHTMLAtoms::colgroup) {
ruleWalker->Forward(mTableColgroupRule);

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

@ -181,7 +181,9 @@ private:
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
};
// this rule handles borders on a <col> when rules is set on its <table>
// this rule handles borders on a <col> when rules is set on its <table>.
// This should only be used for <col>s which are in a colgroup or anonymous
// cols.
class TableColRule;
friend class TableColRule;
class TableColRule: public GenericTableRule {
@ -191,6 +193,17 @@ private:
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
};
// this rule handles borders on a <col> when rules is set on its <table>.
// This should only be used for <col>s which are not in a colgroup.
class TableUngroupedColRule;
friend class TableUngroupedColRule;
class TableUngroupedColRule: public GenericTableRule {
public:
TableUngroupedColRule() {}
NS_IMETHOD MapRuleInfoInto(nsRuleData* aRuleData);
};
nsIURI* mURL;
nsIDocument* mDocument;
HTMLColorRule* mLinkRule;
@ -201,6 +214,7 @@ private:
TableRowRule* mTableRowRule;
TableColgroupRule* mTableColgroupRule;
TableColRule* mTableColRule;
TableUngroupedColRule* mTableUngroupedColRule;
TableTHRule* mTableTHRule;
PLDHashTable mMappedAttrTable;