зеркало из https://github.com/mozilla/gecko-dev.git
Bug 566293 - wrong length of text remove event when inaccessible node containing accessible nodes is removed, r=marcoz, davidb
This commit is contained in:
Родитель
90427451d2
Коммит
23daa1d975
|
@ -1515,7 +1515,7 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
|
|||
|
||||
PRInt32 offset;
|
||||
PRInt32 length = 0;
|
||||
nsCOMPtr<nsIAccessible> changeAccessible =
|
||||
nsAccessible *changeAcc =
|
||||
textAccessible->DOMPointToHypertextOffset(aChangeNode, -1, &offset);
|
||||
|
||||
if (!aAccessibleForChangeNode) {
|
||||
|
@ -1524,33 +1524,29 @@ nsDocAccessible::CreateTextChangeEventForNode(nsIAccessible *aContainerAccessibl
|
|||
// into the parent hypertext.
|
||||
// In this case, accessibleToBeRemoved may just be the first
|
||||
// accessible that is removed, which affects the text in the hypertext container
|
||||
if (!changeAccessible) {
|
||||
if (!changeAcc)
|
||||
return nsnull; // No descendant content that represents any text in the hypertext parent
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> changeNode(do_QueryInterface(aChangeNode));
|
||||
nsCOMPtr<nsIAccessible> child = changeAccessible;
|
||||
while (PR_TRUE) {
|
||||
nsCOMPtr<nsIAccessNode> childAccessNode =
|
||||
do_QueryInterface(changeAccessible);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> childDOMNode;
|
||||
childAccessNode->GetDOMNode(getter_AddRefs(childDOMNode));
|
||||
nsAccessible *parent = changeAcc->GetParent();
|
||||
PRInt32 childCount = parent->GetChildCount();
|
||||
PRInt32 changeAccIdx = parent->GetIndexOf(changeAcc);
|
||||
|
||||
for (PRInt32 idx = changeAccIdx; idx < childCount; idx++) {
|
||||
nsAccessible *child = parent->GetChildAt(idx);
|
||||
nsCOMPtr<nsINode> childNode(do_QueryInterface(child->GetDOMNode()));
|
||||
|
||||
nsCOMPtr<nsINode> childNode(do_QueryInterface(childDOMNode));
|
||||
if (!nsCoreUtils::IsAncestorOf(changeNode, childNode)) {
|
||||
break; // We only want accessibles with DOM nodes as children of this node
|
||||
}
|
||||
length += nsAccUtils::TextLength(child);
|
||||
child->GetNextSibling(getter_AddRefs(changeAccessible));
|
||||
if (!changeAccessible) {
|
||||
// We only want accessibles with DOM nodes as children of this node
|
||||
break;
|
||||
}
|
||||
child.swap(changeAccessible);
|
||||
|
||||
length += nsAccUtils::TextLength(child);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(!changeAccessible || changeAccessible == aAccessibleForChangeNode,
|
||||
NS_ASSERTION(!changeAcc || changeAcc == aAccessibleForChangeNode,
|
||||
"Hypertext is reporting a different accessible for this node");
|
||||
|
||||
length = nsAccUtils::TextLength(aAccessibleForChangeNode);
|
||||
|
|
|
@ -8,6 +8,8 @@ const nsIAccessibleStateChangeEvent =
|
|||
Components.interfaces.nsIAccessibleStateChangeEvent;
|
||||
const nsIAccessibleCaretMoveEvent =
|
||||
Components.interfaces.nsIAccessibleCaretMoveEvent;
|
||||
const nsIAccessibleTextChangeEvent =
|
||||
Components.interfaces.nsIAccessibleTextChangeEvent;
|
||||
|
||||
const nsIAccessibleStates = Components.interfaces.nsIAccessibleStates;
|
||||
const nsIAccessibleRole = Components.interfaces.nsIAccessibleRole;
|
||||
|
|
|
@ -10,6 +10,7 @@ const EVENT_SCROLLING_START = nsIAccessibleEvent.EVENT_SCROLLING_START;
|
|||
const EVENT_SHOW = nsIAccessibleEvent.EVENT_SHOW;
|
||||
const EVENT_STATE_CHANGE = nsIAccessibleEvent.EVENT_STATE_CHANGE;
|
||||
const EVENT_TEXT_CARET_MOVED = nsIAccessibleEvent.EVENT_TEXT_CARET_MOVED;
|
||||
const EVENT_TEXT_REMOVED = nsIAccessibleEvent.EVENT_TEXT_REMOVED;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// General
|
||||
|
|
|
@ -61,6 +61,7 @@ _TEST_FILES =\
|
|||
test_focusdoc.html \
|
||||
test_mutation.html \
|
||||
test_scroll.xul \
|
||||
test_text.html \
|
||||
test_tree.xul \
|
||||
test_valuechange.html \
|
||||
$(NULL)
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>Accessible mutation events testing</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
/**
|
||||
* Invokers.
|
||||
*/
|
||||
function removeChildSpan(aID)
|
||||
{
|
||||
this.DOMNode = getNode(aID);
|
||||
|
||||
this.invoke = function removeChildSpan_invoke()
|
||||
{
|
||||
// remove HTML span, a first child of the node
|
||||
this.DOMNode.removeChild(this.DOMNode.firstChild);
|
||||
}
|
||||
|
||||
this.eventSeq = [
|
||||
new invokerChecker(EVENT_TEXT_REMOVED, this.DOMNode)
|
||||
];
|
||||
|
||||
this.check = function removeChildSpan_check(aEvent)
|
||||
{
|
||||
aEvent.QueryInterface(nsIAccessibleTextChangeEvent);
|
||||
is(aEvent.length, 5, "Wrong length of removed text");
|
||||
}
|
||||
|
||||
this.getID = function focusElmWhileSubdocIsFocused_getID()
|
||||
{
|
||||
return "Remove inaccessible span containing accessible nodes" + prettyName(aID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do tests.
|
||||
*/
|
||||
var gQueue = null;
|
||||
// gA11yEventDumpID = "eventdump"; // debug stuff
|
||||
|
||||
function doTests()
|
||||
{
|
||||
gQueue = new eventQueue();
|
||||
|
||||
// Text remove event on inaccessible child HTML span removal containing
|
||||
// accessible text nodes.
|
||||
gQueue.push(new removeChildSpan("p"));
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTests);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=566293"
|
||||
title=" wrong length of text remove event when inaccessible node containing accessible nodes is removed">
|
||||
Mozilla Bug 566293
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
<div id="eventdump"></div>
|
||||
|
||||
<p id="p"><span><span>333</span><span>22</span></span>1111</p>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче