Bug 1252260 - get rid of HTML table CacheChildren, r=marcoz

This commit is contained in:
Alexander Surkov 2016-03-01 10:54:49 -05:00
parent 7f7bacceb6
commit c970d68052
5 changed files with 89 additions and 15 deletions

View File

@ -590,6 +590,7 @@ public:
HyperTextAccessible* AsHyperText();
bool IsHTMLBr() const { return mType == eHTMLBRType; }
bool IsHTMLCaption() const { return mType == eHTMLCaptionType; }
bool IsHTMLCombobox() const { return mType == eHTMLComboboxType; }
bool IsHTMLFileInput() const { return mType == eHTMLFileInputType; }

View File

@ -393,24 +393,14 @@ NS_IMPL_ISUPPORTS_INHERITED0(HTMLTableAccessible, Accessible)
////////////////////////////////////////////////////////////////////////////////
// HTMLTableAccessible: Accessible
void
HTMLTableAccessible::CacheChildren()
bool
HTMLTableAccessible::InsertChildAt(uint32_t aIndex, Accessible* aChild)
{
// Move caption accessible so that it's the first child. Check for the first
// caption only, because nsAccessibilityService ensures we don't create
// accessibles for the other captions, since only the first is actually
// visible.
TreeWalker walker(this, mContent);
Accessible* child = nullptr;
while ((child = walker.Next())) {
if (child->Role() == roles::CAPTION) {
InsertChildAt(0, child);
while ((child = walker.Next()) && AppendChild(child));
break;
}
AppendChild(child);
}
return Accessible::InsertChildAt(aChild->IsHTMLCaption() ? 0 : aIndex, aChild);
}
role

View File

@ -157,12 +157,13 @@ public:
virtual already_AddRefed<nsIPersistentProperties> NativeAttributes() override;
virtual Relation RelationByType(RelationType aRelationType) override;
bool InsertChildAt(uint32_t aIndex, Accessible* aChild) override;
protected:
virtual ~HTMLTableAccessible() {}
// Accessible
virtual ENameValueFlag NativeName(nsString& aName) override;
virtual void CacheChildren() override;
// HTMLTableAccessible
@ -209,7 +210,7 @@ class HTMLCaptionAccessible : public HyperTextAccessibleWrap
{
public:
HTMLCaptionAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc) { }
HyperTextAccessibleWrap(aContent, aDoc) { mType = eHTMLCaptionType; }
// Accessible
virtual a11y::role NativeRole() override;

View File

@ -29,6 +29,7 @@ skip-if = buildapp == "mulet"
[test_recreation.html]
[test_select.html]
[test_shutdown.xul]
[test_table.html]
[test_textleaf.html]
[test_visibility.html]
[test_whitespace.html]

View File

@ -0,0 +1,81 @@
<!DOCTYPE html>
<html>
<head>
<title>Table update tests</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
function appendCaption(aTableID)
{
this.invoke = function appendCaption_invoke()
{
// append a caption, it should appear as a first element in the
// accessible tree.
var caption = document.createElement("caption");
caption.textContent = "table caption";
getNode(aTableID).appendChild(caption);
}
this.eventSeq = [
new invokerChecker(EVENT_REORDER, aTableID)
];
this.finalCheck = function appendCaption_finalCheck()
{
var tree =
{ TABLE: [
{ CAPTION: [
{ TEXT_LEAF: [] }
] },
{ ROW: [
{ CELL: [ {TEXT_LEAF: [] }]},
{ CELL: [ {TEXT_LEAF: [] }]}
] }
] };
testAccessibleTree(aTableID, tree);
}
this.getID = function appendCaption_getID()
{
return "append caption";
}
}
function doTest()
{
gQueue = new eventQueue();
gQueue.push(new appendCaption("table"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<table id="table">
<tr>
<td>cell1</td>
<td>cell2</td>
</tr>
</table>
</body>
</html>