Fixes #6878: Add limits to the ammount of text we write to the <textarea> for screen readers to avoid stalling the UI.

This commit is contained in:
Alex Dima
2016-05-26 11:53:16 +02:00
parent f60df359cc
commit ca2ca08c63

View File

@@ -400,7 +400,7 @@ export class NVDAPagedTextAreaState extends TextAreaState {
let posttext = model.getValueInRange(posttextRange, EndOfLinePreference.LF);
let text:string = null;
if (selectionStartPage <= selectionEndPage) {
if (selectionStartPage === selectionEndPage || selectionStartPage + 1 === selectionEndPage) {
// take full selection
text = model.getValueInRange(selection, EndOfLinePreference.LF);
} else {
@@ -413,6 +413,19 @@ export class NVDAPagedTextAreaState extends TextAreaState {
);
}
// Chromium handles very poorly text even of a few thousand chars
// Cut text to avoid stalling the entire UI
const LIMIT_CHARS = 500;
if (pretext.length > LIMIT_CHARS) {
pretext = pretext.substring(pretext.length - LIMIT_CHARS, pretext.length);
}
if (posttext.length > LIMIT_CHARS) {
posttext = posttext.substring(0, LIMIT_CHARS);
}
if (text.length > 2 * LIMIT_CHARS) {
text = text.substring(0, LIMIT_CHARS) + String.fromCharCode(8230) + text.substring(text.length - LIMIT_CHARS, text.length);
}
return new NVDAPagedTextAreaState(this, pretext + text + posttext, pretext.length, pretext.length + text.length, false);
}