Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / chromevox / common / braille_text_handler.js
blob36d3e04cba843294d72a733c89191c5b0bae3443
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');
12 /**
13 * @fileoverview Updates braille display contents following text changes.
17 /**
18 * Represents an editable text region.
20 * @constructor
21 * @param {!cvox.BrailleInterface} braille Braille interface.
23 cvox.BrailleTextHandler = function(braille) {
24 /**
25 * Braille interface used to produce output.
26 * @type {!cvox.BrailleInterface}
27 * @private
29 this.braille_ = braille;
33 /**
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
39 * field.
40 * @param {Element} element DOM node which line comes from.
41 * @param {number} lineStart Start offset of line (might be > 0 for multiline
42 * fields).
44 cvox.BrailleTextHandler.prototype.changed = function(
45 line, start, end, multiline, element, lineStart) {
46 var content;
47 if (multiline) {
48 var spannable = cvox.BrailleUtil.createValue(line, start, end, lineStart);
49 if (element) {
50 spannable.setSpan(element, 0, line.length);
52 content = new cvox.NavBraille({text: spannable,
53 startIndex: start,
54 endIndex: end});
55 } else {
56 if (cvox.ChromeVox.navigationManager) {
57 content = cvox.ChromeVox.navigationManager.getBraille();
60 if (content) {
61 this.braille_.write(content);