зеркало из https://github.com/mozilla/gecko-dev.git
Bug 372545. Misidentification of data tables in at-spi based on empty summary or caption. r=nian.liu
This commit is contained in:
Родитель
1a41e7ddf2
Коммит
25af4ee9c2
|
@ -717,7 +717,7 @@ NS_IMETHODIMP nsHTMLTableAccessible::GetDescription(nsAString& aDescription)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName)
|
PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName, PRBool aAllowEmpty)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mDOMNode));
|
nsCOMPtr<nsIDOMElement> tableElt(do_QueryInterface(mDOMNode));
|
||||||
NS_ENSURE_TRUE(tableElt, PR_FALSE);
|
NS_ENSURE_TRUE(tableElt, PR_FALSE);
|
||||||
|
@ -732,9 +732,28 @@ PRBool nsHTMLTableAccessible::HasDescendant(char *aTagName)
|
||||||
|
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
// Make sure it's not the table itself
|
// Make sure it's not the table itself
|
||||||
nsCOMPtr<nsIDOMNode> firstItem;
|
nsCOMPtr<nsIDOMNode> foundItem;
|
||||||
nodeList->Item(0, getter_AddRefs(firstItem));
|
nodeList->Item(0, getter_AddRefs(foundItem));
|
||||||
return firstItem != mDOMNode;
|
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;
|
return length > 0;
|
||||||
|
@ -777,8 +796,10 @@ NS_IMETHODIMP nsHTMLTableAccessible::IsProbablyForLayout(PRBool *aIsProbablyForL
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for legitimate data table elements or attributes
|
// Check for legitimate data table elements or attributes
|
||||||
if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::summary) || HasDescendant("caption") ||
|
nsAutoString summary;
|
||||||
HasDescendant("th") || HasDescendant("thead") || HasDescendant("tfoot") || HasDescendant("colgroup")) {
|
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");
|
RETURN_LAYOUT_ANSWER(PR_FALSE, "Has caption, summary, th, thead, tfoot or colgroup -- legitimate table structures");
|
||||||
}
|
}
|
||||||
if (HasDescendant("table")) {
|
if (HasDescendant("table")) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
||||||
nsresult GetCellAt(PRInt32 aRowIndex,
|
nsresult GetCellAt(PRInt32 aRowIndex,
|
||||||
PRInt32 aColIndex,
|
PRInt32 aColIndex,
|
||||||
nsIDOMElement* &aCell);
|
nsIDOMElement* &aCell);
|
||||||
PRBool HasDescendant(char *aTagName);
|
PRBool HasDescendant(char *aTagName, PRBool aAllowEmpty = PR_TRUE);
|
||||||
PRBool mHasCaption;
|
PRBool mHasCaption;
|
||||||
#ifdef SHOW_LAYOUT_HEURISTIC
|
#ifdef SHOW_LAYOUT_HEURISTIC
|
||||||
nsAutoString mLayoutHeuristic;
|
nsAutoString mLayoutHeuristic;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче