Make WalkContentStyleRules work correctly for XHTML tables without row groups. b=68061 r+sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2003-07-12 22:12:59 +00:00
Родитель 0838577bf0
Коммит 0fdf690be7
1 изменённых файлов: 38 добавлений и 26 удалений

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

@ -90,6 +90,7 @@ protected:
// This does not return a nsresult since all we care about is if we // This does not return a nsresult since all we care about is if we
// found the row element that this cell is in or not. // found the row element that this cell is in or not.
void GetRow(nsIDOMHTMLTableRowElement** aRow); void GetRow(nsIDOMHTMLTableRowElement** aRow);
void GetTable(nsIContent** aTable);
PRInt32 mColIndex; PRInt32 mColIndex;
}; };
@ -200,6 +201,31 @@ nsHTMLTableCellElement::GetRow(nsIDOMHTMLTableRowElement** aRow)
} }
} }
// protected method
void
nsHTMLTableCellElement::GetTable(nsIContent** aTable)
{
*aTable = nsnull;
nsCOMPtr<nsIContent> row;
GetParent(getter_AddRefs(row));
if (row) {
nsCOMPtr<nsIContent> section;
row->GetParent(getter_AddRefs(section));
if (section) {
nsCOMPtr<nsIAtom> tag;
section->GetTag(getter_AddRefs(tag));
if (tag == nsHTMLAtoms::table) {
// XHTML, without a row group
section.swap(*aTable);
} else {
// we have a row group.
section->GetParent(aTable);
}
}
}
}
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex) nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
{ {
@ -244,32 +270,18 @@ nsHTMLTableCellElement::GetCellIndex(PRInt32* aCellIndex)
NS_IMETHODIMP NS_IMETHODIMP
nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
{ {
// get table, add its rules too // Add style information from the mapped attributes of the table
// XXX can we safely presume structure or do we need to QI on the way up? // element. This depends on the strange behavior of the
// XXXldb This needs to handle the possibility (for XHTML) that // |MapAttributesIntoRule| in nsHTMLTableElement.cpp, which is
// there's no row-group. // technically incorrect since it's violating the nsIStyleRule
nsCOMPtr<nsIContent> row; // contract. However, things are OK (except for the incorrect
// dependence on display type rather than tag) since tables and cells
GetParent(getter_AddRefs(row)); // match different, less specific, rules.
nsCOMPtr<nsIContent> table;
if (row) { GetTable(getter_AddRefs(table));
nsCOMPtr<nsIContent> section; nsCOMPtr<nsIStyledContent> styledTable(do_QueryInterface(table));
if (styledTable) {
row->GetParent(getter_AddRefs(section)); styledTable->WalkContentStyleRules(aRuleWalker);
if (section) {
nsCOMPtr<nsIContent> table;
section->GetParent(getter_AddRefs(table));
if (table) {
nsCOMPtr<nsIStyledContent> styledTable(do_QueryInterface(table));
if (styledTable) {
styledTable->WalkContentStyleRules(aRuleWalker);
}
}
}
} }
return nsGenericHTMLContainerElement::WalkContentStyleRules(aRuleWalker); return nsGenericHTMLContainerElement::WalkContentStyleRules(aRuleWalker);