Bug 372545. Misidentification of data tables in at-spi based on empty summary or caption. r=nian.liu

This commit is contained in:
aaronleventhal@moonset.net 2007-04-10 06:29:31 -07:00
Родитель 1a41e7ddf2
Коммит 25af4ee9c2
2 изменённых файлов: 28 добавлений и 7 удалений

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

@ -717,7 +717,7 @@ NS_IMETHODIMP nsHTMLTableAccessible::GetDescription(nsAString& aDescription)
}
#endif
PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName)
PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName, PRBool aAllowEmpty)
{
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(tableElt, PR_FALSE);
@ -732,9 +732,28 @@ PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName)
if (length == 1) {
// Make sure it's not the table itself
nsCOMPtr<nsIDOMNode> firstItem;
nodeList->Item(0, getter_AddRefs(firstItem));
return firstItem != mDOMNode;
nsCOMPtr<nsIDOMNode> foundItem;
nodeList->Item(0, getter_AddRefs(foundItem));
if (foundItem == mDOMNode) {
return PR_FALSE;
}
if (!aAllowEmpty) {
// Make sure that the item we found has contents
// and either has multiple children or the
// found item is not a whitespace-only text node
nsCOMPtr<nsIContent> foundItemContent = do_QueryInterface(foundItem);
if (!foundItemContent) {
return PR_FALSE;
}
if (foundItemContent->GetChildCount() > 1) {
return PR_TRUE; // Treat multiple child nodes as non-empty
}
nsIContent *innerItemContent = foundItemContent->GetChildAt(0);
if (!innerItemContent || innerItemContent->TextIsOnlyWhitespace()) {
return PR_FALSE;
}
}
return PR_TRUE;
}
return length > 0;
@ -777,8 +796,10 @@ NS_IMETHODIMP nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForL
}
// Check for legitimate data table elements or attributes
if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary) || HasDescendant("caption") ||
HasDescendant("th") || HasDescendant("thead") || HasDescendant("tfoot") || HasDescendant("colgroup")) {
nsAutoString summary;
if ((content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary, summary) && !summary.IsEmpty()) ||
HasDescendant("caption", PR_FALSE) || HasDescendant("th") || HasDescendant("thead") ||
HasDescendant("tfoot") || HasDescendant("colgroup")) {
RETURN_LAYOUT_ANSWER(PR_FALSE, "Has caption, summary, th, thead, tfoot or colgroup -- legitimate table structures");
}
if (HasDescendant("table")) {

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

@ -82,7 +82,7 @@ protected:
nsresult GetCellAt(PRInt32 aRowIndex,
PRInt32 aColIndex,
nsIDOMElement* &aCell);
PRBool HasDescendant(char *aTagName);
PRBool HasDescendant(char *aTagName, PRBool aAllowEmpty = PR_TRUE);
PRBool mHasCaption;
#ifdef SHOW_LAYOUT_HEURISTIC
nsAutoString mLayoutHeuristic;