Bug 943603 - Don't let doc accessible keep trailing br, r=tbsaunde

This commit is contained in:
Alexander Surkov 2013-12-09 10:43:51 -05:00
Родитель 6eb6edc7d2
Коммит 21484889ae
3 изменённых файлов: 21 добавлений и 9 удалений

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

@ -1451,10 +1451,22 @@ DocAccessible::CacheChildren()
if (!rootElm) if (!rootElm)
return; return;
// Ignore last HTML:br, copied from HyperTextAccessible.
TreeWalker walker(this, rootElm); TreeWalker walker(this, rootElm);
Accessible* lastChild = nullptr;
while (Accessible* child = walker.NextChild()) {
if (lastChild)
AppendChild(lastChild);
Accessible* child = nullptr; lastChild = child;
while ((child = walker.NextChild()) && AppendChild(child)); }
if (lastChild) {
if (lastChild->IsHTMLBr())
Document()->UnbindFromDocument(lastChild);
else
AppendChild(lastChild);
}
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

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

@ -56,7 +56,7 @@ function editableTextTest(aID)
/** /**
* setTextContents test. * setTextContents test.
*/ */
this.setTextContents = function setTextContents(aValue, aTrailChar) this.setTextContents = function setTextContents(aValue)
{ {
var testID = "setTextContents '" + aValue + "' for " + prettyName(aID); var testID = "setTextContents '" + aValue + "' for " + prettyName(aID);
@ -66,8 +66,7 @@ function editableTextTest(aID)
acc.setTextContents(aValue); acc.setTextContents(aValue);
} }
var newValue = aValue + (aTrailChar ? aTrailChar : ""); var insertTripple = aValue ? [0, aValue.length, aValue] : null;
var insertTripple = newValue ? [0, newValue.length, newValue] : null;
var oldValue = getValue(aID); var oldValue = getValue(aID);
var removeTripple = oldValue ? [0, oldValue.length, oldValue] : null; var removeTripple = oldValue ? [0, oldValue.length, oldValue] : null;

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

@ -20,14 +20,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452161
<script type="application/javascript"> <script type="application/javascript">
function addTestEditable(aID, aTestRun, aTrailChar) function addTestEditable(aID, aTestRun)
{ {
var et = new editableTextTest(aID); var et = new editableTextTest(aID);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// setTextContents // setTextContents
et.scheduleTest(et.setTextContents, "hello"); et.scheduleTest(et.setTextContents, "hello");
et.scheduleTest(et.setTextContents, "olleh", aTrailChar); // due to some reason this reports '\n' in the end et.scheduleTest(et.setTextContents, "olleh");
et.scheduleTest(et.setTextContents, ""); et.scheduleTest(et.setTextContents, "");
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -80,9 +80,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452161
{ {
// Prepare tested elements. // Prepare tested elements.
// Design mode on/off trigger document accessible subtree recreation. // Design mode on/off triggers an editable state change event on
// the document accessible.
var frame = getNode("frame"); var frame = getNode("frame");
waitForEvent(EVENT_REORDER, frame.contentDocument, runTest); waitForEvent(EVENT_STATE_CHANGE, frame.contentDocument, runTest);
frame.contentDocument.designMode = "on"; frame.contentDocument.designMode = "on";
} }