Bug 499093 - Fix discrepancy between tr count and row count in nsHTMLTableAccessible::IsProbablyForLayout, r=marcoz

This commit is contained in:
Alexander Surkov 2012-02-17 16:21:26 +09:00
Родитель 571cebe9d0
Коммит 1b5c98d62e
1 изменённых файлов: 18 добавлений и 22 удалений

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

@ -1494,28 +1494,24 @@ nsHTMLTableAccessible::IsProbablyForLayout(bool *aIsProbablyForLayout)
* Rules for non-bordered tables with 2-4 columns and 2+ rows from here on forward
*/
// Check for styled background color across the row
// Alternating background color is a common way
nsCOMPtr<nsIDOMNodeList> nodeList;
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mContent));
tableElt->GetElementsByTagName(NS_LITERAL_STRING("tr"), getter_AddRefs(nodeList));
NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);
PRUint32 length;
nodeList->GetLength(&length);
nsAutoString color, lastRowColor;
for (PRUint32 rowCount = 0; rowCount < length; rowCount ++) {
nsCOMPtr<nsIDOMNode> rowNode;
nodeList->Item(rowCount, getter_AddRefs(rowNode));
nsCOMPtr<nsIContent> rowContent(do_QueryInterface(rowNode));
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(), rowContent);
NS_ENSURE_TRUE(styleDecl, NS_ERROR_FAILURE);
lastRowColor = color;
styleDecl->GetPropertyValue(NS_LITERAL_STRING("background-color"), color);
if (rowCount > 0 && false == lastRowColor.Equals(color)) {
RETURN_LAYOUT_ANSWER(false, "2 styles of row background color, non-bordered");
// Check for styled background color across rows (alternating background
// color is a common feature for data tables).
PRUint32 childCount = GetChildCount();
nsAutoString rowColor, prevRowColor;
for (PRUint32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible* child = GetChildAt(childIdx);
if (child->Role() == roles::ROW) {
nsCOMPtr<nsIDOMCSSStyleDeclaration> styleDecl =
nsCoreUtils::GetComputedStyleDeclaration(EmptyString(),
child->GetContent());
if (styleDecl) {
prevRowColor = rowColor;
styleDecl->GetPropertyValue(NS_LITERAL_STRING("background-color"),
rowColor);
if (childIdx > 0 && !prevRowColor.Equals(rowColor)) {
RETURN_LAYOUT_ANSWER(false, "2 styles of row background color, non-bordered");
}
}
}
}