1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 goog.provide('cvox.BrailleTextHandler');
7 goog.require('cvox.BrailleInterface');
8 goog.require('cvox.BrailleUtil');
9 goog.require('cvox.ChromeVox');
10 goog.require('cvox.NavBraille');
13 * @fileoverview Updates braille display contents following text changes.
18 * Represents an editable text region.
21 * @param {!cvox.BrailleInterface} braille Braille interface.
23 cvox.BrailleTextHandler = function(braille) {
25 * Braille interface used to produce output.
26 * @type {!cvox.BrailleInterface}
29 this.braille_ = braille;
34 * Called by controller class when text changes.
35 * @param {string} line The text of the line.
36 * @param {number} start The 0-based index starting selection.
37 * @param {number} end The 0-based index ending selection.
38 * @param {boolean} multiline True if the text comes from a multi line text
40 * @param {Element} element DOM node which line comes from.
41 * @param {number} lineStart Start offset of line (might be > 0 for multiline
44 cvox.BrailleTextHandler.prototype.changed = function(
45 line, start, end, multiline, element, lineStart) {
48 var spannable = cvox.BrailleUtil.createValue(line, start, end, lineStart);
50 spannable.setSpan(element, 0, line.length);
52 content = new cvox.NavBraille({text: spannable,
56 if (cvox.ChromeVox.navigationManager) {
57 content = cvox.ChromeVox.navigationManager.getBraille();
61 this.braille_.write(content);