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

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

Issue 2263513004: Add support for rich output inside of content editables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@editable_nav
Patch Set: Test fixes. Created 4 years, 4 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 4d988b800c8c900b622593c4226cc21756f989f1..74c6e59523fc65036cb3218f8141cd6a5eb326a8 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/editing.js
@@ -21,7 +21,7 @@ goog.scope(function() {
var AutomationEvent = chrome.automation.AutomationEvent;
var AutomationNode = chrome.automation.AutomationNode;
var Cursor = cursors.Cursor;
-var Dir = AutomationUtil.Dir;
+var Dir = constants.Dir;
var EventType = chrome.automation.EventType;
var Range = cursors.Range;
var RoleType = chrome.automation.RoleType;
@@ -141,6 +141,20 @@ AutomationEditableText.prototype = {
},
/** @override */
+ describeLine: function(lineIndex, triggeredByUser) {
+ if (!this.node_.state.richlyEditable) {
+ cvox.ChromeVoxEditableTextBase.prototype.describeLine.call(
+ this, lineIndex, triggeredByUser);
+ return;
+ }
+ var line = this.getSelectedAutomationLine_();
+ if (line) {
+ new Output().withRichSpeech(line, null, Output.EventType.NAVIGATE)
+ .go();
+ }
+ },
+
+ /** @override */
getLineStart: function(lineIndex) {
if (!this.multiline || lineIndex == 0)
return 0;
@@ -173,25 +187,42 @@ AutomationEditableText.prototype = {
/** @private */
outputBraille_: function() {
- var isFirstLine = false; // First line in a multiline field.
+ // First line in a multiline field.
+ var lineIndex = this.getLineIndex(this.start);
+ var isFirstLine = this.multiline && lineIndex == 0;
var output = new Output();
var range;
- if (this.multiline) {
- var lineIndex = this.getLineIndex(this.start);
- if (lineIndex == 0) {
- isFirstLine = true;
+ if (this.node_.state.richlyEditable) {
+ range = this.getSelectedAutomationLine_();
+ } else if (this.multiline) {
+ if (isFirstLine)
output.formatForBraille('$name', this.node_);
- }
range = new Range(
new Cursor(this.node_, this.getLineStart(lineIndex)),
new Cursor(this.node_, this.getLineEnd(lineIndex)));
} else {
range = Range.fromNode(this.node_);
}
- output.withBraille(range, null, Output.EventType.NAVIGATE);
+ if (range)
+ output.withBraille(range, null, Output.EventType.NAVIGATE);
if (isFirstLine)
output.formatForBraille('@tag_textarea');
output.go();
+ },
+
+ /**
+ * @return {Range}
+ * @private
+ */
+ getSelectedAutomationLine_: function() {
+ if (!this.node_.root.anchorObject || !this.node_.root.focusObject)
+ return null;
+
+ var start = Cursor.fromNode(this.node_.root.anchorObject);
+ start = start.move(Unit.LINE, Movement.BOUND, Dir.BACKWARD);
+ var end = Cursor.fromNode(this.node_.root.focusObject);
+ end = end.move(Unit.LINE, Movement.BOUND, Dir.FORWARD);
+ return new Range(start, end);
}
};

Powered by Google App Engine
This is Rietveld 408576698