Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js

Issue 2931893002: More precise use of multiline state (Closed)
Patch Set: Fix typo Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
index 60580fdf46907cc59796295313c5f1c2032817e3..8d548279306ee53973a12ef4ac05cf69b443ba4c 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
@@ -114,12 +114,8 @@ function AutomationEditableText(node) {
cvox.ChromeVoxEditableTextBase.call(
this, node.value || '', Math.min(start, end), Math.max(start, end),
node.state[StateType.PROTECTED] /**password*/, cvox.ChromeVox.tts);
- /** @override */
- this.multiline = node.state[StateType.MULTILINE] || false;
/** @type {!AutomationNode} @private */
this.node_ = node;
- /** @type {Array<number>} @private */
- this.lineBreaks_ = [];
}
AutomationEditableText.prototype = {
@@ -131,9 +127,6 @@ AutomationEditableText.prototype = {
onUpdate: function() {
var newValue = this.node_.value || '';
- if (this.value != newValue)
- this.lineBreaks_ = [];
-
var textChangeEvent = new cvox.TextChangeEvent(
newValue, this.node_.textSelStart || 0, this.node_.textSelEnd || 0,
true /* triggered by user */);
@@ -143,9 +136,9 @@ AutomationEditableText.prototype = {
/** @override */
getLineIndex: function(charIndex) {
- if (!this.multiline)
- return 0;
var breaks = this.node_.lineBreaks || [];
+ if (!breaks.length)
+ return 0;
var index = 0;
while (index < breaks.length && breaks[index] <= charIndex)
++index;
@@ -154,9 +147,11 @@ AutomationEditableText.prototype = {
/** @override */
getLineStart: function(lineIndex) {
- if (!this.multiline || lineIndex == 0)
+ if (lineIndex == 0)
return 0;
var breaks = this.getLineBreaks_();
+ if (breaks.length < 1)
+ return 0;
return breaks[lineIndex - 1] || this.node_.value.length;
},
@@ -184,7 +179,7 @@ AutomationEditableText.prototype = {
var isFirstLine = false; // First line in a multiline field.
var output = new Output();
var range;
- if (this.multiline) {
+ if (this.getLineBreaks_().length) {
David Tseng 2017/06/27 18:41:14 This isn't equivalent. Whether something is not mu
var lineIndex = this.getLineIndex(this.start);
if (lineIndex == 0) {
isFirstLine = true;

Powered by Google App Engine
This is Rietveld 408576698