/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
mHyperText = parent->AsHyperText(); if (!mHyperText) {
MOZ_ASSERT_UNREACHABLE("Text leaf parent is not hypertext!"); return;
}
// Get the text leaf accessible offset and invalidate cached offsets after it.
mTextOffset = mHyperText->GetChildOffset(mTextLeaf, true);
NS_ASSERTION(mTextOffset != -1, "Text leaf hasn't offset within hyper text!");
// Don't bother diffing if the hypertext isn't editable. Diffing non-editable // text can lead to weird screen reader results with live regions, e.g., // changing "text" to "testing" might read the diff "s ing" when we'd really // just like to hear "testing." if (!mHyperText->IsEditable()) { // Fire text change event for removal.
RefPtr<AccEvent> textRemoveEvent = new AccTextChangeEvent(mHyperText, mTextOffset, aOldText, false);
mDocument->FireDelayedEvent(textRemoveEvent);
// Fire text change event for insertion if there's text to insert. if (!aNewText.IsEmpty()) {
RefPtr<AccEvent> textInsertEvent = new AccTextChangeEvent(mHyperText, mTextOffset, aNewText, true);
mDocument->FireDelayedEvent(textInsertEvent);
}
mDocument->MaybeNotifyOfValueChange(mHyperText);
// Update the text.
mTextLeaf->SetText(aNewText); return;
}
// Increase offset of the text leaf on skipped characters amount.
mTextOffset += aSkipStart;
// It could be single insertion or removal or the case of long strings. Do not // calculate the difference between long strings and prefer to fire pair of // insert/remove events as the old string was replaced on the new one. if (strLen1 == 0 || strLen2 == 0 || strLen1 > kMaxStrLen ||
strLen2 > kMaxStrLen) { if (strLen1 > 0) { // Fire text change event for removal.
RefPtr<AccEvent> textRemoveEvent = new AccTextChangeEvent(mHyperText, mTextOffset, str1, false);
mDocument->FireDelayedEvent(textRemoveEvent);
}
if (strLen2 > 0) { // Fire text change event for insertion.
RefPtr<AccEvent> textInsertEvent = new AccTextChangeEvent(mHyperText, mTextOffset, str2, true);
mDocument->FireDelayedEvent(textInsertEvent);
}
mDocument->MaybeNotifyOfValueChange(mHyperText);
// Update the text.
mTextLeaf->SetText(aNewText); return;
}
// Otherwise find the difference between strings and fire events. // Note: we can skip initial and final coinciding characters since they don't // affect the Levenshtein distance.
// Compute the flat structured matrix need to compute the difference.
uint32_t len1 = strLen1 + 1, len2 = strLen2 + 1;
uint32_t* entries = new uint32_t[len1 * len2];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.